{"ast":null,"code":"import React from 'react';\nvar isCheckBoxInput = element => element.type === 'checkbox';\nvar isDateObject = value => value instanceof Date;\nvar isNullOrUndefined = value => value == null;\nconst isObjectType = value => typeof value === 'object';\nvar isObject = value => !isNullOrUndefined(value) && !Array.isArray(value) && isObjectType(value) && !isDateObject(value);\nvar getEventValue = event => isObject(event) && event.target ? isCheckBoxInput(event.target) ? event.target.checked : event.target.value : event;\nvar getNodeParentName = name => name.substring(0, name.search(/\\.\\d+(\\.|$)/)) || name;\nvar isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));\nvar compact = value => Array.isArray(value) ? value.filter(Boolean) : [];\nvar isUndefined = val => val === undefined;\nvar get = (obj, path, defaultValue) => {\n  if (!path || !isObject(obj)) {\n    return defaultValue;\n  }\n  const result = compact(path.split(/[,[\\].]+?/)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], obj);\n  return isUndefined(result) || result === obj ? isUndefined(obj[path]) ? defaultValue : obj[path] : result;\n};\nconst EVENTS = {\n  BLUR: 'blur',\n  FOCUS_OUT: 'focusout',\n  CHANGE: 'change'\n};\nconst VALIDATION_MODE = {\n  onBlur: 'onBlur',\n  onChange: 'onChange',\n  onSubmit: 'onSubmit',\n  onTouched: 'onTouched',\n  all: 'all'\n};\nconst INPUT_VALIDATION_RULES = {\n  max: 'max',\n  min: 'min',\n  maxLength: 'maxLength',\n  minLength: 'minLength',\n  pattern: 'pattern',\n  required: 'required',\n  validate: 'validate'\n};\nconst HookFormContext = React.createContext(null);\n/**\r\n * This custom hook allows you to access the form context. useFormContext is intended to be used in deeply nested structures, where it would become inconvenient to pass the context as a prop. To be used with {@link FormProvider}.\r\n *\r\n * @remarks\r\n * [API](https://react-hook-form.com/api/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)\r\n *\r\n * @returns return all useForm methods\r\n *\r\n * @example\r\n * ```tsx\r\n * function App() {\r\n *   const methods = useForm();\r\n *   const onSubmit = data => console.log(data);\r\n *\r\n *   return (\r\n *     <FormProvider {...methods} >\r\n *       <form onSubmit={methods.handleSubmit(onSubmit)}>\r\n *         <NestedInput />\r\n *         <input type=\"submit\" />\r\n *       </form>\r\n *     </FormProvider>\r\n *   );\r\n * }\r\n *\r\n *  function NestedInput() {\r\n *   const { register } = useFormContext(); // retrieve all hook methods\r\n *   return <input {...register(\"test\")} />;\r\n * }\r\n * ```\r\n */\nconst useFormContext = () => React.useContext(HookFormContext);\n/**\r\n * A provider component that propagates the `useForm` methods to all children components via [React Context](https://reactjs.org/docs/context.html) API. To be used with {@link useFormContext}.\r\n *\r\n * @remarks\r\n * [API](https://react-hook-form.com/api/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)\r\n *\r\n * @param props - all useFrom methods\r\n *\r\n * @example\r\n * ```tsx\r\n * function App() {\r\n *   const methods = useForm();\r\n *   const onSubmit = data => console.log(data);\r\n *\r\n *   return (\r\n *     <FormProvider {...methods} >\r\n *       <form onSubmit={methods.handleSubmit(onSubmit)}>\r\n *         <NestedInput />\r\n *         <input type=\"submit\" />\r\n *       </form>\r\n *     </FormProvider>\r\n *   );\r\n * }\r\n *\r\n *  function NestedInput() {\r\n *   const { register } = useFormContext(); // retrieve all hook methods\r\n *   return <input {...register(\"test\")} />;\r\n * }\r\n * ```\r\n */\nconst FormProvider = props => {\n  const {\n    children,\n    ...data\n  } = props;\n  return React.createElement(HookFormContext.Provider, {\n    value: data\n  }, children);\n};\nvar getProxyFormState = function (formState, control, localProxyFormState) {\n  let isRoot = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;\n  const result = {\n    defaultValues: control._defaultValues\n  };\n  for (const key in formState) {\n    Object.defineProperty(result, key, {\n      get: () => {\n        const _key = key;\n        if (control._proxyFormState[_key] !== VALIDATION_MODE.all) {\n          control._proxyFormState[_key] = !isRoot || VALIDATION_MODE.all;\n        }\n        localProxyFormState && (localProxyFormState[_key] = true);\n        return formState[_key];\n      }\n    });\n  }\n  return result;\n};\nvar isEmptyObject = value => isObject(value) && !Object.keys(value).length;\nvar shouldRenderFormState = (formStateData, _proxyFormState, isRoot) => {\n  const {\n    name,\n    ...formState\n  } = formStateData;\n  return isEmptyObject(formState) || Object.keys(formState).length >= Object.keys(_proxyFormState).length || Object.keys(formState).find(key => _proxyFormState[key] === (!isRoot || VALIDATION_MODE.all));\n};\nvar convertToArrayPayload = value => Array.isArray(value) ? value : [value];\nvar shouldSubscribeByName = (name, signalName, exact) => exact && signalName ? name === signalName : !name || !signalName || name === signalName || convertToArrayPayload(name).some(currentName => currentName && (currentName.startsWith(signalName) || signalName.startsWith(currentName)));\nfunction useSubscribe(props) {\n  const _props = React.useRef(props);\n  _props.current = props;\n  React.useEffect(() => {\n    const subscription = !props.disabled && _props.current.subject.subscribe({\n      next: _props.current.callback\n    });\n    return () => {\n      subscription && subscription.unsubscribe();\n    };\n  }, [props.disabled]);\n}\n\n/**\r\n * This custom hook allows you to subscribe to each form state, and isolate the re-render at the custom hook level. It has its scope in terms of form state subscription, so it would not affect other useFormState and useForm. Using this hook can reduce the re-render impact on large and complex form application.\r\n *\r\n * @remarks\r\n * [API](https://react-hook-form.com/api/useformstate) • [Demo](https://codesandbox.io/s/useformstate-75xly)\r\n *\r\n * @param props - include options on specify fields to subscribe. {@link UseFormStateReturn}\r\n *\r\n * @example\r\n * ```tsx\r\n * function App() {\r\n *   const { register, handleSubmit, control } = useForm({\r\n *     defaultValues: {\r\n *     firstName: \"firstName\"\r\n *   }});\r\n *   const { dirtyFields } = useFormState({\r\n *     control\r\n *   });\r\n *   const onSubmit = (data) => console.log(data);\r\n *\r\n *   return (\r\n *     <form onSubmit={handleSubmit(onSubmit)}>\r\n *       <input {...register(\"firstName\")} placeholder=\"First Name\" />\r\n *       {dirtyFields.firstName && <p>Field is dirty.</p>}\r\n *       <input type=\"submit\" />\r\n *     </form>\r\n *   );\r\n * }\r\n * ```\r\n */\nfunction useFormState(props) {\n  const methods = useFormContext();\n  const {\n    control = methods.control,\n    disabled,\n    name,\n    exact\n  } = props || {};\n  const [formState, updateFormState] = React.useState(control._formState);\n  const _mounted = React.useRef(true);\n  const _localProxyFormState = React.useRef({\n    isDirty: false,\n    dirtyFields: false,\n    touchedFields: false,\n    isValidating: false,\n    isValid: false,\n    errors: false\n  });\n  const _name = React.useRef(name);\n  _name.current = name;\n  useSubscribe({\n    disabled,\n    callback: React.useCallback(value => _mounted.current && shouldSubscribeByName(_name.current, value.name, exact) && shouldRenderFormState(value, _localProxyFormState.current) && updateFormState({\n      ...control._formState,\n      ...value\n    }), [control, exact]),\n    subject: control._subjects.state\n  });\n  React.useEffect(() => {\n    _mounted.current = true;\n    return () => {\n      _mounted.current = false;\n    };\n  }, []);\n  return getProxyFormState(formState, control, _localProxyFormState.current, false);\n}\nvar isString = value => typeof value === 'string';\nvar generateWatchOutput = (names, _names, formValues, isGlobal) => {\n  const isArray = Array.isArray(names);\n  if (isString(names)) {\n    isGlobal && _names.watch.add(names);\n    return get(formValues, names);\n  }\n  if (isArray) {\n    return names.map(fieldName => (isGlobal && _names.watch.add(fieldName), get(formValues, fieldName)));\n  }\n  isGlobal && (_names.watchAll = true);\n  return formValues;\n};\nvar isFunction = value => typeof value === 'function';\nvar objectHasFunction = data => {\n  for (const key in data) {\n    if (isFunction(data[key])) {\n      return true;\n    }\n  }\n  return false;\n};\n\n/**\r\n * Custom hook to subscribe to field change and isolate re-rendering at the component level.\r\n *\r\n * @remarks\r\n *\r\n * [API](https://react-hook-form.com/api/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)\r\n *\r\n * @example\r\n * ```tsx\r\n * const { watch } = useForm();\r\n * const values = useWatch({\r\n *   name: \"fieldName\"\r\n *   control,\r\n * })\r\n * ```\r\n */\nfunction useWatch(props) {\n  const methods = useFormContext();\n  const {\n    control = methods.control,\n    name,\n    defaultValue,\n    disabled,\n    exact\n  } = props || {};\n  const _name = React.useRef(name);\n  _name.current = name;\n  useSubscribe({\n    disabled,\n    subject: control._subjects.watch,\n    callback: React.useCallback(formState => {\n      if (shouldSubscribeByName(_name.current, formState.name, exact)) {\n        const fieldValues = generateWatchOutput(_name.current, control._names, formState.values || control._formValues);\n        updateValue(isUndefined(_name.current) || isObject(fieldValues) && !objectHasFunction(fieldValues) ? {\n          ...fieldValues\n        } : Array.isArray(fieldValues) ? [...fieldValues] : isUndefined(fieldValues) ? defaultValue : fieldValues);\n      }\n    }, [control, exact, defaultValue])\n  });\n  const [value, updateValue] = React.useState(isUndefined(defaultValue) ? control._getWatch(name) : defaultValue);\n  React.useEffect(() => control._removeUnmounted());\n  return value;\n}\n\n/**\r\n * Custom hook to work with controlled component, this function provide you with both form and field level state. Re-render is isolated at the hook level.\r\n *\r\n * @remarks\r\n * [API](https://react-hook-form.com/api/usecontroller) • [Demo](https://codesandbox.io/s/usecontroller-0o8px)\r\n *\r\n * @param props - the path name to the form field value, and validation rules.\r\n *\r\n * @returns field properties, field and form state. {@link UseControllerReturn}\r\n *\r\n * @example\r\n * ```tsx\r\n * function Input(props) {\r\n *   const { field, fieldState, formState } = useController(props);\r\n *   return (\r\n *     <div>\r\n *       <input {...field} placeholder={props.name} />\r\n *       <p>{fieldState.isTouched && \"Touched\"}</p>\r\n *       <p>{formState.isSubmitted ? \"submitted\" : \"\"}</p>\r\n *     </div>\r\n *   );\r\n * }\r\n * ```\r\n */\nfunction useController(props) {\n  const methods = useFormContext();\n  const {\n    name,\n    control = methods.control,\n    shouldUnregister\n  } = props;\n  const isArrayField = isNameInFieldArray(control._names.array, name);\n  const value = useWatch({\n    control,\n    name,\n    defaultValue: get(control._formValues, name, get(control._defaultValues, name, props.defaultValue)),\n    exact: true\n  });\n  const formState = useFormState({\n    control,\n    name\n  });\n  const _registerProps = React.useRef(control.register(name, {\n    ...props.rules,\n    value\n  }));\n  React.useEffect(() => {\n    const updateMounted = (name, value) => {\n      const field = get(control._fields, name);\n      if (field) {\n        field._f.mount = value;\n      }\n    };\n    updateMounted(name, true);\n    return () => {\n      const _shouldUnregisterField = control._options.shouldUnregister || shouldUnregister;\n      (isArrayField ? _shouldUnregisterField && !control._stateFlags.action : _shouldUnregisterField) ? control.unregister(name) : updateMounted(name, false);\n    };\n  }, [name, control, isArrayField, shouldUnregister]);\n  return {\n    field: {\n      name,\n      value,\n      onChange: React.useCallback(event => _registerProps.current.onChange({\n        target: {\n          value: getEventValue(event),\n          name: name\n        },\n        type: EVENTS.CHANGE\n      }), [name]),\n      onBlur: React.useCallback(() => _registerProps.current.onBlur({\n        target: {\n          value: get(control._formValues, name),\n          name: name\n        },\n        type: EVENTS.BLUR\n      }), [name, control]),\n      ref: elm => {\n        const field = get(control._fields, name);\n        if (field && elm) {\n          field._f.ref = {\n            focus: () => elm.focus(),\n            select: () => elm.select(),\n            setCustomValidity: message => elm.setCustomValidity(message),\n            reportValidity: () => elm.reportValidity()\n          };\n        }\n      }\n    },\n    formState,\n    fieldState: Object.defineProperties({}, {\n      invalid: {\n        enumerable: true,\n        get: () => !!get(formState.errors, name)\n      },\n      isDirty: {\n        enumerable: true,\n        get: () => !!get(formState.dirtyFields, name)\n      },\n      isTouched: {\n        enumerable: true,\n        get: () => !!get(formState.touchedFields, name)\n      },\n      error: {\n        enumerable: true,\n        get: () => get(formState.errors, name)\n      }\n    })\n  };\n}\n\n/**\r\n * Component based on `useController` hook to work with controlled component.\r\n *\r\n * @remarks\r\n * [API](https://react-hook-form.com/api/usecontroller/controller) • [Demo](https://codesandbox.io/s/react-hook-form-v6-controller-ts-jwyzw) • [Video](https://www.youtube.com/watch?v=N2UNk_UCVyA)\r\n *\r\n * @param props - the path name to the form field value, and validation rules.\r\n *\r\n * @returns provide field handler functions, field and form state.\r\n *\r\n * @example\r\n * ```tsx\r\n * function App() {\r\n *   const { control } = useForm<FormValues>({\r\n *     defaultValues: {\r\n *       test: \"\"\r\n *     }\r\n *   });\r\n *\r\n *   return (\r\n *     <form>\r\n *       <Controller\r\n *         control={control}\r\n *         name=\"test\"\r\n *         render={({ field: { onChange, onBlur, value, ref }, formState, fieldState }) => (\r\n *           <>\r\n *             <input\r\n *               onChange={onChange} // send value to hook form\r\n *               onBlur={onBlur} // notify when input is touched\r\n *               value={value} // return updated value\r\n *               ref={ref} // set ref for focus management\r\n *             />\r\n *             <p>{formState.isSubmitted ? \"submitted\" : \"\"}</p>\r\n *             <p>{fieldState.isTouched ? \"touched\" : \"\"}</p>\r\n *           </>\r\n *         )}\r\n *       />\r\n *     </form>\r\n *   );\r\n * }\r\n * ```\r\n */\nconst Controller = props => props.render(useController(props));\nvar appendErrors = (name, validateAllFieldCriteria, errors, type, message) => validateAllFieldCriteria ? {\n  ...errors[name],\n  types: {\n    ...(errors[name] && errors[name].types ? errors[name].types : {}),\n    [type]: message || true\n  }\n} : {};\nvar isKey = value => /^\\w*$/.test(value);\nvar stringToPath = input => compact(input.replace(/[\"|']|\\]/g, '').split(/\\.|\\[/));\nfunction set(object, path, value) {\n  let index = -1;\n  const tempPath = isKey(path) ? [path] : stringToPath(path);\n  const length = tempPath.length;\n  const lastIndex = length - 1;\n  while (++index < length) {\n    const key = tempPath[index];\n    let newValue = value;\n    if (index !== lastIndex) {\n      const objValue = object[key];\n      newValue = isObject(objValue) || Array.isArray(objValue) ? objValue : !isNaN(+tempPath[index + 1]) ? [] : {};\n    }\n    object[key] = newValue;\n    object = object[key];\n  }\n  return object;\n}\nconst focusFieldBy = (fields, callback, fieldsNames) => {\n  for (const key of fieldsNames || Object.keys(fields)) {\n    const field = get(fields, key);\n    if (field) {\n      const {\n        _f,\n        ...currentField\n      } = field;\n      if (_f && callback(_f.name)) {\n        if (_f.ref.focus) {\n          _f.ref.focus();\n          break;\n        } else if (_f.refs && _f.refs[0].focus) {\n          _f.refs[0].focus();\n          break;\n        }\n      } else if (isObject(currentField)) {\n        focusFieldBy(currentField, callback);\n      }\n    }\n  }\n};\nvar generateId = () => {\n  const d = typeof performance === 'undefined' ? Date.now() : performance.now() * 1000;\n  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {\n    const r = (Math.random() * 16 + d) % 16 | 0;\n    return (c == 'x' ? r : r & 0x3 | 0x8).toString(16);\n  });\n};\nvar getFocusFieldName = function (name, index) {\n  let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n  return options.shouldFocus || isUndefined(options.shouldFocus) ? options.focusName || `${name}.${isUndefined(options.focusIndex) ? index : options.focusIndex}.` : '';\n};\nvar isWatched = (name, _names, isBlurEvent) => !isBlurEvent && (_names.watchAll || _names.watch.has(name) || [..._names.watch].some(watchName => name.startsWith(watchName) && /^\\.\\w+/.test(name.slice(watchName.length))));\nvar updateFieldArrayRootError = (errors, error, name) => {\n  const fieldArrayErrors = compact(get(errors, name));\n  set(fieldArrayErrors, 'root', error[name]);\n  set(errors, name, fieldArrayErrors);\n  return errors;\n};\nvar isBoolean = value => typeof value === 'boolean';\nvar isFileInput = element => element.type === 'file';\nvar isMessage = value => isString(value) || React.isValidElement(value);\nvar isRadioInput = element => element.type === 'radio';\nvar isRegex = value => value instanceof RegExp;\nconst defaultResult = {\n  value: false,\n  isValid: false\n};\nconst validResult = {\n  value: true,\n  isValid: true\n};\nvar getCheckboxValue = options => {\n  if (Array.isArray(options)) {\n    if (options.length > 1) {\n      const values = options.filter(option => option && option.checked && !option.disabled).map(option => option.value);\n      return {\n        value: values,\n        isValid: !!values.length\n      };\n    }\n    return options[0].checked && !options[0].disabled ?\n    // @ts-expect-error expected to work in the browser\n    options[0].attributes && !isUndefined(options[0].attributes.value) ? isUndefined(options[0].value) || options[0].value === '' ? validResult : {\n      value: options[0].value,\n      isValid: true\n    } : validResult : defaultResult;\n  }\n  return defaultResult;\n};\nconst defaultReturn = {\n  isValid: false,\n  value: null\n};\nvar getRadioValue = options => Array.isArray(options) ? options.reduce((previous, option) => option && option.checked && !option.disabled ? {\n  isValid: true,\n  value: option.value\n} : previous, defaultReturn) : defaultReturn;\nfunction getValidateError(result, ref) {\n  let type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'validate';\n  if (isMessage(result) || Array.isArray(result) && result.every(isMessage) || isBoolean(result) && !result) {\n    return {\n      type,\n      message: isMessage(result) ? result : '',\n      ref\n    };\n  }\n}\nvar getValueAndMessage = validationData => isObject(validationData) && !isRegex(validationData) ? validationData : {\n  value: validationData,\n  message: ''\n};\nvar validateField = async (field, inputValue, validateAllFieldCriteria, shouldUseNativeValidation, isFieldArray) => {\n  const {\n    ref,\n    refs,\n    required,\n    maxLength,\n    minLength,\n    min,\n    max,\n    pattern,\n    validate,\n    name,\n    valueAsNumber,\n    mount,\n    disabled\n  } = field._f;\n  if (!mount || disabled) {\n    return {};\n  }\n  const inputRef = refs ? refs[0] : ref;\n  const setCustomValidity = message => {\n    if (shouldUseNativeValidation && inputRef.reportValidity) {\n      inputRef.setCustomValidity(isBoolean(message) ? '' : message || ' ');\n      inputRef.reportValidity();\n    }\n  };\n  const error = {};\n  const isRadio = isRadioInput(ref);\n  const isCheckBox = isCheckBoxInput(ref);\n  const isRadioOrCheckbox = isRadio || isCheckBox;\n  const isEmpty = (valueAsNumber || isFileInput(ref)) && !ref.value || inputValue === '' || Array.isArray(inputValue) && !inputValue.length;\n  const appendErrorsCurry = appendErrors.bind(null, name, validateAllFieldCriteria, error);\n  const getMinMaxMessage = function (exceedMax, maxLengthMessage, minLengthMessage) {\n    let maxType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : INPUT_VALIDATION_RULES.maxLength;\n    let minType = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : INPUT_VALIDATION_RULES.minLength;\n    const message = exceedMax ? maxLengthMessage : minLengthMessage;\n    error[name] = {\n      type: exceedMax ? maxType : minType,\n      message,\n      ref,\n      ...appendErrorsCurry(exceedMax ? maxType : minType, message)\n    };\n  };\n  if (isFieldArray ? !Array.isArray(inputValue) || !inputValue.length : required && (!isRadioOrCheckbox && (isEmpty || isNullOrUndefined(inputValue)) || isBoolean(inputValue) && !inputValue || isCheckBox && !getCheckboxValue(refs).isValid || isRadio && !getRadioValue(refs).isValid)) {\n    const {\n      value,\n      message\n    } = isMessage(required) ? {\n      value: !!required,\n      message: required\n    } : getValueAndMessage(required);\n    if (value) {\n      error[name] = {\n        type: INPUT_VALIDATION_RULES.required,\n        message,\n        ref: inputRef,\n        ...appendErrorsCurry(INPUT_VALIDATION_RULES.required, message)\n      };\n      if (!validateAllFieldCriteria) {\n        setCustomValidity(message);\n        return error;\n      }\n    }\n  }\n  if (!isEmpty && (!isNullOrUndefined(min) || !isNullOrUndefined(max))) {\n    let exceedMax;\n    let exceedMin;\n    const maxOutput = getValueAndMessage(max);\n    const minOutput = getValueAndMessage(min);\n    if (!isNullOrUndefined(inputValue) && !isNaN(inputValue)) {\n      const valueNumber = ref.valueAsNumber || (inputValue ? +inputValue : inputValue);\n      if (!isNullOrUndefined(maxOutput.value)) {\n        exceedMax = valueNumber > maxOutput.value;\n      }\n      if (!isNullOrUndefined(minOutput.value)) {\n        exceedMin = valueNumber < minOutput.value;\n      }\n    } else {\n      const valueDate = ref.valueAsDate || new Date(inputValue);\n      const convertTimeToDate = time => new Date(new Date().toDateString() + ' ' + time);\n      const isTime = ref.type == 'time';\n      const isWeek = ref.type == 'week';\n      if (isString(maxOutput.value) && inputValue) {\n        exceedMax = isTime ? convertTimeToDate(inputValue) > convertTimeToDate(maxOutput.value) : isWeek ? inputValue > maxOutput.value : valueDate > new Date(maxOutput.value);\n      }\n      if (isString(minOutput.value) && inputValue) {\n        exceedMin = isTime ? convertTimeToDate(inputValue) < convertTimeToDate(minOutput.value) : isWeek ? inputValue < minOutput.value : valueDate < new Date(minOutput.value);\n      }\n    }\n    if (exceedMax || exceedMin) {\n      getMinMaxMessage(!!exceedMax, maxOutput.message, minOutput.message, INPUT_VALIDATION_RULES.max, INPUT_VALIDATION_RULES.min);\n      if (!validateAllFieldCriteria) {\n        setCustomValidity(error[name].message);\n        return error;\n      }\n    }\n  }\n  if ((maxLength || minLength) && !isEmpty && (isString(inputValue) || isFieldArray && Array.isArray(inputValue))) {\n    const maxLengthOutput = getValueAndMessage(maxLength);\n    const minLengthOutput = getValueAndMessage(minLength);\n    const exceedMax = !isNullOrUndefined(maxLengthOutput.value) && inputValue.length > maxLengthOutput.value;\n    const exceedMin = !isNullOrUndefined(minLengthOutput.value) && inputValue.length < minLengthOutput.value;\n    if (exceedMax || exceedMin) {\n      getMinMaxMessage(exceedMax, maxLengthOutput.message, minLengthOutput.message);\n      if (!validateAllFieldCriteria) {\n        setCustomValidity(error[name].message);\n        return error;\n      }\n    }\n  }\n  if (pattern && !isEmpty && isString(inputValue)) {\n    const {\n      value: patternValue,\n      message\n    } = getValueAndMessage(pattern);\n    if (isRegex(patternValue) && !inputValue.match(patternValue)) {\n      error[name] = {\n        type: INPUT_VALIDATION_RULES.pattern,\n        message,\n        ref,\n        ...appendErrorsCurry(INPUT_VALIDATION_RULES.pattern, message)\n      };\n      if (!validateAllFieldCriteria) {\n        setCustomValidity(message);\n        return error;\n      }\n    }\n  }\n  if (validate) {\n    if (isFunction(validate)) {\n      const result = await validate(inputValue);\n      const validateError = getValidateError(result, inputRef);\n      if (validateError) {\n        error[name] = {\n          ...validateError,\n          ...appendErrorsCurry(INPUT_VALIDATION_RULES.validate, validateError.message)\n        };\n        if (!validateAllFieldCriteria) {\n          setCustomValidity(validateError.message);\n          return error;\n        }\n      }\n    } else if (isObject(validate)) {\n      let validationResult = {};\n      for (const key in validate) {\n        if (!isEmptyObject(validationResult) && !validateAllFieldCriteria) {\n          break;\n        }\n        const validateError = getValidateError(await validate[key](inputValue), inputRef, key);\n        if (validateError) {\n          validationResult = {\n            ...validateError,\n            ...appendErrorsCurry(key, validateError.message)\n          };\n          setCustomValidity(validateError.message);\n          if (validateAllFieldCriteria) {\n            error[name] = validationResult;\n          }\n        }\n      }\n      if (!isEmptyObject(validationResult)) {\n        error[name] = {\n          ref: inputRef,\n          ...validationResult\n        };\n        if (!validateAllFieldCriteria) {\n          return error;\n        }\n      }\n    }\n  }\n  setCustomValidity(true);\n  return error;\n};\nfunction append(data, value) {\n  return [...data, ...convertToArrayPayload(value)];\n}\nvar isPlainObject = tempObject => {\n  const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;\n  return isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf');\n};\nvar isWeb = typeof window !== 'undefined' && typeof window.HTMLElement !== 'undefined' && typeof document !== 'undefined';\nfunction cloneObject(data) {\n  let copy;\n  const isArray = Array.isArray(data);\n  if (data instanceof Date) {\n    copy = new Date(data);\n  } else if (data instanceof Set) {\n    copy = new Set(data);\n  } else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) && (isArray || isObject(data))) {\n    copy = isArray ? [] : {};\n    if (!Array.isArray(data) && !isPlainObject(data)) {\n      copy = data;\n    } else {\n      for (const key in data) {\n        copy[key] = cloneObject(data[key]);\n      }\n    }\n  } else {\n    return data;\n  }\n  return copy;\n}\nvar fillEmptyArray = value => Array.isArray(value) ? value.map(() => undefined) : undefined;\nvar getValidationModes = mode => ({\n  isOnSubmit: !mode || mode === VALIDATION_MODE.onSubmit,\n  isOnBlur: mode === VALIDATION_MODE.onBlur,\n  isOnChange: mode === VALIDATION_MODE.onChange,\n  isOnAll: mode === VALIDATION_MODE.all,\n  isOnTouch: mode === VALIDATION_MODE.onTouched\n});\nfunction insert(data, index, value) {\n  return [...data.slice(0, index), ...convertToArrayPayload(value), ...data.slice(index)];\n}\nvar moveArrayAt = (data, from, to) => {\n  if (!Array.isArray(data)) {\n    return [];\n  }\n  if (isUndefined(data[to])) {\n    data[to] = undefined;\n  }\n  data.splice(to, 0, data.splice(from, 1)[0]);\n  return data;\n};\nfunction prepend(data, value) {\n  return [...convertToArrayPayload(value), ...convertToArrayPayload(data)];\n}\nfunction removeAtIndexes(data, indexes) {\n  let i = 0;\n  const temp = [...data];\n  for (const index of indexes) {\n    temp.splice(index - i, 1);\n    i++;\n  }\n  return compact(temp).length ? temp : [];\n}\nvar removeArrayAt = (data, index) => isUndefined(index) ? [] : removeAtIndexes(data, convertToArrayPayload(index).sort((a, b) => a - b));\nvar swapArrayAt = (data, indexA, indexB) => {\n  data[indexA] = [data[indexB], data[indexB] = data[indexA]][0];\n};\nfunction baseGet(object, updatePath) {\n  const length = updatePath.slice(0, -1).length;\n  let index = 0;\n  while (index < length) {\n    object = isUndefined(object) ? index++ : object[updatePath[index++]];\n  }\n  return object;\n}\nfunction isEmptyArray(obj) {\n  for (const key in obj) {\n    if (!isUndefined(obj[key])) {\n      return false;\n    }\n  }\n  return true;\n}\nfunction unset(object, path) {\n  const updatePath = isKey(path) ? [path] : stringToPath(path);\n  const childObject = updatePath.length == 1 ? object : baseGet(object, updatePath);\n  const key = updatePath[updatePath.length - 1];\n  let previousObjRef;\n  if (childObject) {\n    delete childObject[key];\n  }\n  for (let k = 0; k < updatePath.slice(0, -1).length; k++) {\n    let index = -1;\n    let objectRef;\n    const currentPaths = updatePath.slice(0, -(k + 1));\n    const currentPathsLength = currentPaths.length - 1;\n    if (k > 0) {\n      previousObjRef = object;\n    }\n    while (++index < currentPaths.length) {\n      const item = currentPaths[index];\n      objectRef = objectRef ? objectRef[item] : object[item];\n      if (currentPathsLength === index && (isObject(objectRef) && isEmptyObject(objectRef) || Array.isArray(objectRef) && isEmptyArray(objectRef))) {\n        previousObjRef ? delete previousObjRef[item] : delete object[item];\n      }\n      previousObjRef = objectRef;\n    }\n  }\n  return object;\n}\nvar updateAt = (fieldValues, index, value) => {\n  fieldValues[index] = value;\n  return fieldValues;\n};\n\n/**\r\n * A custom hook that exposes convenient methods to perform operations with a list of dynamic inputs that need to be appended, updated, removed etc. • [Demo](https://codesandbox.io/s/react-hook-form-usefieldarray-ssugn) • [Video](https://youtu.be/4MrbfGSFY2A)\r\n *\r\n * @remarks\r\n * [API](https://react-hook-form.com/api/usefieldarray) • [Demo](https://codesandbox.io/s/react-hook-form-usefieldarray-ssugn)\r\n *\r\n * @param props - useFieldArray props\r\n *\r\n * @returns methods - functions to manipulate with the Field Arrays (dynamic inputs) {@link UseFieldArrayReturn}\r\n *\r\n * @example\r\n * ```tsx\r\n * function App() {\r\n *   const { register, control, handleSubmit, reset, trigger, setError } = useForm({\r\n *     defaultValues: {\r\n *       test: []\r\n *     }\r\n *   });\r\n *   const { fields, append } = useFieldArray({\r\n *     control,\r\n *     name: \"test\"\r\n *   });\r\n *\r\n *   return (\r\n *     <form onSubmit={handleSubmit(data => console.log(data))}>\r\n *       {fields.map((item, index) => (\r\n *          <input key={item.id} {...register(`test.${index}.firstName`)}  />\r\n *       ))}\r\n *       <button type=\"button\" onClick={() => append({ firstName: \"bill\" })}>\r\n *         append\r\n *       </button>\r\n *       <input type=\"submit\" />\r\n *     </form>\r\n *   );\r\n * }\r\n * ```\r\n */\nfunction useFieldArray(props) {\n  const methods = useFormContext();\n  const {\n    control = methods.control,\n    name,\n    keyName = 'id',\n    shouldUnregister\n  } = props;\n  const [fields, setFields] = React.useState(control._getFieldArray(name));\n  const ids = React.useRef(control._getFieldArray(name).map(generateId));\n  const _fieldIds = React.useRef(fields);\n  const _name = React.useRef(name);\n  const _actioned = React.useRef(false);\n  _name.current = name;\n  _fieldIds.current = fields;\n  control._names.array.add(name);\n  props.rules && control.register(name, props.rules);\n  const callback = React.useCallback(_ref => {\n    let {\n      values,\n      name: fieldArrayName\n    } = _ref;\n    if (fieldArrayName === _name.current || !fieldArrayName) {\n      const fieldValues = get(values, _name.current);\n      if (Array.isArray(fieldValues)) {\n        setFields(fieldValues);\n        ids.current = fieldValues.map(generateId);\n      }\n    }\n  }, []);\n  useSubscribe({\n    callback,\n    subject: control._subjects.array\n  });\n  const updateValues = React.useCallback(updatedFieldArrayValues => {\n    _actioned.current = true;\n    control._updateFieldArray(name, updatedFieldArrayValues);\n  }, [control, name]);\n  const append$1 = (value, options) => {\n    const appendValue = convertToArrayPayload(cloneObject(value));\n    const updatedFieldArrayValues = append(control._getFieldArray(name), appendValue);\n    control._names.focus = getFocusFieldName(name, updatedFieldArrayValues.length - 1, options);\n    ids.current = append(ids.current, appendValue.map(generateId));\n    updateValues(updatedFieldArrayValues);\n    setFields(updatedFieldArrayValues);\n    control._updateFieldArray(name, updatedFieldArrayValues, append, {\n      argA: fillEmptyArray(value)\n    });\n  };\n  const prepend$1 = (value, options) => {\n    const prependValue = convertToArrayPayload(cloneObject(value));\n    const updatedFieldArrayValues = prepend(control._getFieldArray(name), prependValue);\n    control._names.focus = getFocusFieldName(name, 0, options);\n    ids.current = prepend(ids.current, prependValue.map(generateId));\n    updateValues(updatedFieldArrayValues);\n    setFields(updatedFieldArrayValues);\n    control._updateFieldArray(name, updatedFieldArrayValues, prepend, {\n      argA: fillEmptyArray(value)\n    });\n  };\n  const remove = index => {\n    const updatedFieldArrayValues = removeArrayAt(control._getFieldArray(name), index);\n    ids.current = removeArrayAt(ids.current, index);\n    updateValues(updatedFieldArrayValues);\n    setFields(updatedFieldArrayValues);\n    control._updateFieldArray(name, updatedFieldArrayValues, removeArrayAt, {\n      argA: index\n    });\n  };\n  const insert$1 = (index, value, options) => {\n    const insertValue = convertToArrayPayload(cloneObject(value));\n    const updatedFieldArrayValues = insert(control._getFieldArray(name), index, insertValue);\n    control._names.focus = getFocusFieldName(name, index, options);\n    ids.current = insert(ids.current, index, insertValue.map(generateId));\n    updateValues(updatedFieldArrayValues);\n    setFields(updatedFieldArrayValues);\n    control._updateFieldArray(name, updatedFieldArrayValues, insert, {\n      argA: index,\n      argB: fillEmptyArray(value)\n    });\n  };\n  const swap = (indexA, indexB) => {\n    const updatedFieldArrayValues = control._getFieldArray(name);\n    swapArrayAt(updatedFieldArrayValues, indexA, indexB);\n    swapArrayAt(ids.current, indexA, indexB);\n    updateValues(updatedFieldArrayValues);\n    setFields(updatedFieldArrayValues);\n    control._updateFieldArray(name, updatedFieldArrayValues, swapArrayAt, {\n      argA: indexA,\n      argB: indexB\n    }, false);\n  };\n  const move = (from, to) => {\n    const updatedFieldArrayValues = control._getFieldArray(name);\n    moveArrayAt(updatedFieldArrayValues, from, to);\n    moveArrayAt(ids.current, from, to);\n    updateValues(updatedFieldArrayValues);\n    setFields(updatedFieldArrayValues);\n    control._updateFieldArray(name, updatedFieldArrayValues, moveArrayAt, {\n      argA: from,\n      argB: to\n    }, false);\n  };\n  const update = (index, value) => {\n    const updateValue = cloneObject(value);\n    const updatedFieldArrayValues = updateAt(control._getFieldArray(name), index, updateValue);\n    ids.current = [...updatedFieldArrayValues].map((item, i) => !item || i === index ? generateId() : ids.current[i]);\n    updateValues(updatedFieldArrayValues);\n    setFields([...updatedFieldArrayValues]);\n    control._updateFieldArray(name, updatedFieldArrayValues, updateAt, {\n      argA: index,\n      argB: updateValue\n    }, true, false);\n  };\n  const replace = value => {\n    const updatedFieldArrayValues = convertToArrayPayload(cloneObject(value));\n    ids.current = updatedFieldArrayValues.map(generateId);\n    updateValues([...updatedFieldArrayValues]);\n    setFields([...updatedFieldArrayValues]);\n    control._updateFieldArray(name, [...updatedFieldArrayValues], data => data, {}, true, false);\n  };\n  React.useEffect(() => {\n    control._stateFlags.action = false;\n    isWatched(name, control._names) && control._subjects.state.next({});\n    if (_actioned.current && (!getValidationModes(control._options.mode).isOnSubmit || control._formState.isSubmitted)) {\n      if (control._options.resolver) {\n        control._executeSchema([name]).then(result => {\n          const error = get(result.errors, name);\n          const existingError = get(control._formState.errors, name);\n          if (existingError ? !error && existingError.type : error && error.type) {\n            error ? set(control._formState.errors, name, error) : unset(control._formState.errors, name);\n            control._subjects.state.next({\n              errors: control._formState.errors\n            });\n          }\n        });\n      } else {\n        const field = get(control._fields, name);\n        if (field && field._f) {\n          validateField(field, get(control._formValues, name), control._options.criteriaMode === VALIDATION_MODE.all, control._options.shouldUseNativeValidation, true).then(error => !isEmptyObject(error) && control._subjects.state.next({\n            errors: updateFieldArrayRootError(control._formState.errors, error, name)\n          }));\n        }\n      }\n    }\n    control._subjects.watch.next({\n      name,\n      values: control._formValues\n    });\n    control._names.focus && focusFieldBy(control._fields, key => !!key && key.startsWith(control._names.focus));\n    control._names.focus = '';\n    control._proxyFormState.isValid && control._updateValid();\n  }, [fields, name, control]);\n  React.useEffect(() => {\n    !get(control._formValues, name) && control._updateFieldArray(name);\n    return () => {\n      (control._options.shouldUnregister || shouldUnregister) && control.unregister(name);\n    };\n  }, [name, control, keyName, shouldUnregister]);\n  return {\n    swap: React.useCallback(swap, [updateValues, name, control]),\n    move: React.useCallback(move, [updateValues, name, control]),\n    prepend: React.useCallback(prepend$1, [updateValues, name, control]),\n    append: React.useCallback(append$1, [updateValues, name, control]),\n    remove: React.useCallback(remove, [updateValues, name, control]),\n    insert: React.useCallback(insert$1, [updateValues, name, control]),\n    update: React.useCallback(update, [updateValues, name, control]),\n    replace: React.useCallback(replace, [updateValues, name, control]),\n    fields: React.useMemo(() => fields.map((field, index) => ({\n      ...field,\n      [keyName]: ids.current[index] || generateId()\n    })), [fields, keyName])\n  };\n}\nfunction createSubject() {\n  let _observers = [];\n  const next = value => {\n    for (const observer of _observers) {\n      observer.next(value);\n    }\n  };\n  const subscribe = observer => {\n    _observers.push(observer);\n    return {\n      unsubscribe: () => {\n        _observers = _observers.filter(o => o !== observer);\n      }\n    };\n  };\n  const unsubscribe = () => {\n    _observers = [];\n  };\n  return {\n    get observers() {\n      return _observers;\n    },\n    next,\n    subscribe,\n    unsubscribe\n  };\n}\nvar isPrimitive = value => isNullOrUndefined(value) || !isObjectType(value);\nfunction deepEqual(object1, object2) {\n  if (isPrimitive(object1) || isPrimitive(object2)) {\n    return object1 === object2;\n  }\n  if (isDateObject(object1) && isDateObject(object2)) {\n    return object1.getTime() === object2.getTime();\n  }\n  const keys1 = Object.keys(object1);\n  const keys2 = Object.keys(object2);\n  if (keys1.length !== keys2.length) {\n    return false;\n  }\n  for (const key of keys1) {\n    const val1 = object1[key];\n    if (!keys2.includes(key)) {\n      return false;\n    }\n    if (key !== 'ref') {\n      const val2 = object2[key];\n      if (isDateObject(val1) && isDateObject(val2) || isObject(val1) && isObject(val2) || Array.isArray(val1) && Array.isArray(val2) ? !deepEqual(val1, val2) : val1 !== val2) {\n        return false;\n      }\n    }\n  }\n  return true;\n}\nvar isHTMLElement = value => {\n  const owner = value ? value.ownerDocument : 0;\n  const ElementClass = owner && owner.defaultView ? owner.defaultView.HTMLElement : HTMLElement;\n  return value instanceof ElementClass;\n};\nvar isMultipleSelect = element => element.type === `select-multiple`;\nvar isRadioOrCheckbox = ref => isRadioInput(ref) || isCheckBoxInput(ref);\nvar live = ref => isHTMLElement(ref) && ref.isConnected;\nfunction markFieldsDirty(data) {\n  let fields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n  const isParentNodeArray = Array.isArray(data);\n  if (isObject(data) || isParentNodeArray) {\n    for (const key in data) {\n      if (Array.isArray(data[key]) || isObject(data[key]) && !objectHasFunction(data[key])) {\n        fields[key] = Array.isArray(data[key]) ? [] : {};\n        markFieldsDirty(data[key], fields[key]);\n      } else if (!isNullOrUndefined(data[key])) {\n        fields[key] = true;\n      }\n    }\n  }\n  return fields;\n}\nfunction getDirtyFieldsFromDefaultValues(data, formValues, dirtyFieldsFromValues) {\n  const isParentNodeArray = Array.isArray(data);\n  if (isObject(data) || isParentNodeArray) {\n    for (const key in data) {\n      if (Array.isArray(data[key]) || isObject(data[key]) && !objectHasFunction(data[key])) {\n        if (isUndefined(formValues) || isPrimitive(dirtyFieldsFromValues[key])) {\n          dirtyFieldsFromValues[key] = Array.isArray(data[key]) ? markFieldsDirty(data[key], []) : {\n            ...markFieldsDirty(data[key])\n          };\n        } else {\n          getDirtyFieldsFromDefaultValues(data[key], isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);\n        }\n      } else {\n        dirtyFieldsFromValues[key] = !deepEqual(data[key], formValues[key]);\n      }\n    }\n  }\n  return dirtyFieldsFromValues;\n}\nvar getDirtyFields = (defaultValues, formValues) => getDirtyFieldsFromDefaultValues(defaultValues, formValues, markFieldsDirty(formValues));\nvar getFieldValueAs = (value, _ref2) => {\n  let {\n    valueAsNumber,\n    valueAsDate,\n    setValueAs\n  } = _ref2;\n  return isUndefined(value) ? value : valueAsNumber ? value === '' ? NaN : value ? +value : value : valueAsDate && isString(value) ? new Date(value) : setValueAs ? setValueAs(value) : value;\n};\nfunction getFieldValue(_f) {\n  const ref = _f.ref;\n  if (_f.refs ? _f.refs.every(ref => ref.disabled) : ref.disabled) {\n    return;\n  }\n  if (isFileInput(ref)) {\n    return ref.files;\n  }\n  if (isRadioInput(ref)) {\n    return getRadioValue(_f.refs).value;\n  }\n  if (isMultipleSelect(ref)) {\n    return [...ref.selectedOptions].map(_ref3 => {\n      let {\n        value\n      } = _ref3;\n      return value;\n    });\n  }\n  if (isCheckBoxInput(ref)) {\n    return getCheckboxValue(_f.refs).value;\n  }\n  return getFieldValueAs(isUndefined(ref.value) ? _f.ref.value : ref.value, _f);\n}\nvar getResolverOptions = (fieldsNames, _fields, criteriaMode, shouldUseNativeValidation) => {\n  const fields = {};\n  for (const name of fieldsNames) {\n    const field = get(_fields, name);\n    field && set(fields, name, field._f);\n  }\n  return {\n    criteriaMode,\n    names: [...fieldsNames],\n    fields,\n    shouldUseNativeValidation\n  };\n};\nvar getRuleValue = rule => isUndefined(rule) ? undefined : isRegex(rule) ? rule.source : isObject(rule) ? isRegex(rule.value) ? rule.value.source : rule.value : rule;\nvar hasValidation = options => options.mount && (options.required || options.min || options.max || options.maxLength || options.minLength || options.pattern || options.validate);\nfunction schemaErrorLookup(errors, _fields, name) {\n  const error = get(errors, name);\n  if (error || isKey(name)) {\n    return {\n      error,\n      name\n    };\n  }\n  const names = name.split('.');\n  while (names.length) {\n    const fieldName = names.join('.');\n    const field = get(_fields, fieldName);\n    const foundError = get(errors, fieldName);\n    if (field && !Array.isArray(field) && name !== fieldName) {\n      return {\n        name\n      };\n    }\n    if (foundError && foundError.type) {\n      return {\n        name: fieldName,\n        error: foundError\n      };\n    }\n    names.pop();\n  }\n  return {\n    name\n  };\n}\nvar skipValidation = (isBlurEvent, isTouched, isSubmitted, reValidateMode, mode) => {\n  if (mode.isOnAll) {\n    return false;\n  } else if (!isSubmitted && mode.isOnTouch) {\n    return !(isTouched || isBlurEvent);\n  } else if (isSubmitted ? reValidateMode.isOnBlur : mode.isOnBlur) {\n    return !isBlurEvent;\n  } else if (isSubmitted ? reValidateMode.isOnChange : mode.isOnChange) {\n    return isBlurEvent;\n  }\n  return true;\n};\nvar unsetEmptyArray = (ref, name) => !compact(get(ref, name)).length && unset(ref, name);\nconst defaultOptions = {\n  mode: VALIDATION_MODE.onSubmit,\n  reValidateMode: VALIDATION_MODE.onChange,\n  shouldFocusError: true\n};\nfunction createFormControl() {\n  let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n  let _options = {\n    ...defaultOptions,\n    ...props\n  };\n  let _formState = {\n    submitCount: 0,\n    isDirty: false,\n    isValidating: false,\n    isSubmitted: false,\n    isSubmitting: false,\n    isSubmitSuccessful: false,\n    isValid: false,\n    touchedFields: {},\n    dirtyFields: {},\n    errors: {}\n  };\n  let _fields = {};\n  let _defaultValues = cloneObject(_options.defaultValues) || {};\n  let _formValues = _options.shouldUnregister ? {} : cloneObject(_defaultValues);\n  let _stateFlags = {\n    action: false,\n    mount: false,\n    watch: false\n  };\n  let _names = {\n    mount: new Set(),\n    unMount: new Set(),\n    array: new Set(),\n    watch: new Set()\n  };\n  let delayErrorCallback;\n  let timer = 0;\n  let validateFields = {};\n  const _proxyFormState = {\n    isDirty: false,\n    dirtyFields: false,\n    touchedFields: false,\n    isValidating: false,\n    isValid: false,\n    errors: false\n  };\n  const _subjects = {\n    watch: createSubject(),\n    array: createSubject(),\n    state: createSubject()\n  };\n  const validationModeBeforeSubmit = getValidationModes(_options.mode);\n  const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);\n  const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;\n  const debounce = callback => wait => {\n    clearTimeout(timer);\n    timer = window.setTimeout(callback, wait);\n  };\n  const _updateValid = async shouldSkipRender => {\n    let isValid = false;\n    if (_proxyFormState.isValid) {\n      isValid = _options.resolver ? isEmptyObject((await _executeSchema()).errors) : await executeBuiltInValidation(_fields, true);\n      if (!shouldSkipRender && isValid !== _formState.isValid) {\n        _formState.isValid = isValid;\n        _subjects.state.next({\n          isValid\n        });\n      }\n    }\n    return isValid;\n  };\n  const _updateFieldArray = function (name) {\n    let values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n    let method = arguments.length > 2 ? arguments[2] : undefined;\n    let args = arguments.length > 3 ? arguments[3] : undefined;\n    let shouldSetValues = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;\n    let shouldUpdateFieldsAndState = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;\n    if (args && method) {\n      _stateFlags.action = true;\n      if (shouldUpdateFieldsAndState && Array.isArray(get(_fields, name))) {\n        const fieldValues = method(get(_fields, name), args.argA, args.argB);\n        shouldSetValues && set(_fields, name, fieldValues);\n      }\n      if (_proxyFormState.errors && shouldUpdateFieldsAndState && Array.isArray(get(_formState.errors, name))) {\n        const errors = method(get(_formState.errors, name), args.argA, args.argB);\n        shouldSetValues && set(_formState.errors, name, errors);\n        unsetEmptyArray(_formState.errors, name);\n      }\n      if (_proxyFormState.touchedFields && shouldUpdateFieldsAndState && Array.isArray(get(_formState.touchedFields, name))) {\n        const touchedFields = method(get(_formState.touchedFields, name), args.argA, args.argB);\n        shouldSetValues && set(_formState.touchedFields, name, touchedFields);\n      }\n      if (_proxyFormState.dirtyFields) {\n        _formState.dirtyFields = getDirtyFields(_defaultValues, _formValues);\n      }\n      _subjects.state.next({\n        isDirty: _getDirty(name, values),\n        dirtyFields: _formState.dirtyFields,\n        errors: _formState.errors,\n        isValid: _formState.isValid\n      });\n    } else {\n      set(_formValues, name, values);\n    }\n  };\n  const updateErrors = (name, error) => {\n    set(_formState.errors, name, error);\n    _subjects.state.next({\n      errors: _formState.errors\n    });\n  };\n  const updateValidAndValue = (name, shouldSkipSetValueAs, value, ref) => {\n    const field = get(_fields, name);\n    if (field) {\n      const defaultValue = get(_formValues, name, isUndefined(value) ? get(_defaultValues, name) : value);\n      isUndefined(defaultValue) || ref && ref.defaultChecked || shouldSkipSetValueAs ? set(_formValues, name, shouldSkipSetValueAs ? defaultValue : getFieldValue(field._f)) : setFieldValue(name, defaultValue);\n      _stateFlags.mount && _updateValid();\n    }\n  };\n  const updateTouchAndDirty = (name, fieldValue, isBlurEvent, shouldDirty, shouldRender) => {\n    let isFieldDirty = false;\n    const output = {\n      name\n    };\n    const isPreviousFieldTouched = get(_formState.touchedFields, name);\n    if (_proxyFormState.isDirty) {\n      const isPreviousFormDirty = _formState.isDirty;\n      _formState.isDirty = output.isDirty = _getDirty();\n      isFieldDirty = isPreviousFormDirty !== output.isDirty;\n    }\n    if (_proxyFormState.dirtyFields && (!isBlurEvent || shouldDirty)) {\n      const isPreviousFieldDirty = get(_formState.dirtyFields, name);\n      const isCurrentFieldPristine = deepEqual(get(_defaultValues, name), fieldValue);\n      isCurrentFieldPristine ? unset(_formState.dirtyFields, name) : set(_formState.dirtyFields, name, true);\n      output.dirtyFields = _formState.dirtyFields;\n      isFieldDirty = isFieldDirty || isPreviousFieldDirty !== get(_formState.dirtyFields, name);\n    }\n    if (isBlurEvent && !isPreviousFieldTouched) {\n      set(_formState.touchedFields, name, isBlurEvent);\n      output.touchedFields = _formState.touchedFields;\n      isFieldDirty = isFieldDirty || _proxyFormState.touchedFields && isPreviousFieldTouched !== isBlurEvent;\n    }\n    isFieldDirty && shouldRender && _subjects.state.next(output);\n    return isFieldDirty ? output : {};\n  };\n  const shouldRenderByError = async (name, isValid, error, fieldState) => {\n    const previousFieldError = get(_formState.errors, name);\n    const shouldUpdateValid = _proxyFormState.isValid && _formState.isValid !== isValid;\n    if (props.delayError && error) {\n      delayErrorCallback = debounce(() => updateErrors(name, error));\n      delayErrorCallback(props.delayError);\n    } else {\n      clearTimeout(timer);\n      delayErrorCallback = null;\n      error ? set(_formState.errors, name, error) : unset(_formState.errors, name);\n    }\n    if ((error ? !deepEqual(previousFieldError, error) : previousFieldError) || !isEmptyObject(fieldState) || shouldUpdateValid) {\n      const updatedFormState = {\n        ...fieldState,\n        ...(shouldUpdateValid ? {\n          isValid\n        } : {}),\n        errors: _formState.errors,\n        name\n      };\n      _formState = {\n        ..._formState,\n        ...updatedFormState\n      };\n      _subjects.state.next(updatedFormState);\n    }\n    validateFields[name]--;\n    if (_proxyFormState.isValidating && !Object.values(validateFields).some(v => v)) {\n      _subjects.state.next({\n        isValidating: false\n      });\n      validateFields = {};\n    }\n  };\n  const _executeSchema = async name => _options.resolver ? await _options.resolver({\n    ..._formValues\n  }, _options.context, getResolverOptions(name || _names.mount, _fields, _options.criteriaMode, _options.shouldUseNativeValidation)) : {};\n  const executeSchemaAndUpdateState = async names => {\n    const {\n      errors\n    } = await _executeSchema();\n    if (names) {\n      for (const name of names) {\n        const error = get(errors, name);\n        error ? set(_formState.errors, name, error) : unset(_formState.errors, name);\n      }\n    } else {\n      _formState.errors = errors;\n    }\n    return errors;\n  };\n  const executeBuiltInValidation = async function (fields, shouldOnlyCheckValid) {\n    let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {\n      valid: true\n    };\n    for (const name in fields) {\n      const field = fields[name];\n      if (field) {\n        const {\n          _f,\n          ...fieldValue\n        } = field;\n        if (_f) {\n          const isFieldArrayRoot = _names.array.has(_f.name);\n          const fieldError = await validateField(field, get(_formValues, _f.name), shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation, isFieldArrayRoot);\n          if (fieldError[_f.name]) {\n            context.valid = false;\n            if (shouldOnlyCheckValid) {\n              break;\n            }\n          }\n          !shouldOnlyCheckValid && (get(fieldError, _f.name) ? isFieldArrayRoot ? updateFieldArrayRootError(_formState.errors, fieldError, _f.name) : set(_formState.errors, _f.name, fieldError[_f.name]) : unset(_formState.errors, _f.name));\n        }\n        fieldValue && (await executeBuiltInValidation(fieldValue, shouldOnlyCheckValid, context));\n      }\n    }\n    return context.valid;\n  };\n  const _removeUnmounted = () => {\n    for (const name of _names.unMount) {\n      const field = get(_fields, name);\n      field && (field._f.refs ? field._f.refs.every(ref => !live(ref)) : !live(field._f.ref)) && unregister(name);\n    }\n    _names.unMount = new Set();\n  };\n  const _getDirty = (name, data) => (name && data && set(_formValues, name, data), !deepEqual(getValues(), _defaultValues));\n  const _getWatch = (names, defaultValue, isGlobal) => {\n    const fieldValues = {\n      ...(_stateFlags.mount ? _formValues : isUndefined(defaultValue) ? _defaultValues : isString(names) ? {\n        [names]: defaultValue\n      } : defaultValue)\n    };\n    return generateWatchOutput(names, _names, fieldValues, isGlobal);\n  };\n  const _getFieldArray = name => compact(get(_stateFlags.mount ? _formValues : _defaultValues, name, props.shouldUnregister ? get(_defaultValues, name, []) : []));\n  const setFieldValue = function (name, value) {\n    let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n    const field = get(_fields, name);\n    let fieldValue = value;\n    if (field) {\n      const fieldReference = field._f;\n      if (fieldReference) {\n        !fieldReference.disabled && set(_formValues, name, getFieldValueAs(value, fieldReference));\n        fieldValue = isWeb && isHTMLElement(fieldReference.ref) && isNullOrUndefined(value) ? '' : value;\n        if (isMultipleSelect(fieldReference.ref)) {\n          [...fieldReference.ref.options].forEach(optionRef => optionRef.selected = fieldValue.includes(optionRef.value));\n        } else if (fieldReference.refs) {\n          if (isCheckBoxInput(fieldReference.ref)) {\n            fieldReference.refs.length > 1 ? fieldReference.refs.forEach(checkboxRef => (!checkboxRef.defaultChecked || !checkboxRef.disabled) && (checkboxRef.checked = Array.isArray(fieldValue) ? !!fieldValue.find(data => data === checkboxRef.value) : fieldValue === checkboxRef.value)) : fieldReference.refs[0] && (fieldReference.refs[0].checked = !!fieldValue);\n          } else {\n            fieldReference.refs.forEach(radioRef => radioRef.checked = radioRef.value === fieldValue);\n          }\n        } else if (isFileInput(fieldReference.ref)) {\n          fieldReference.ref.value = '';\n        } else {\n          fieldReference.ref.value = fieldValue;\n          if (!fieldReference.ref.type) {\n            _subjects.watch.next({\n              name\n            });\n          }\n        }\n      }\n    }\n    (options.shouldDirty || options.shouldTouch) && updateTouchAndDirty(name, fieldValue, options.shouldTouch, options.shouldDirty, true);\n    options.shouldValidate && trigger(name);\n  };\n  const setValues = (name, value, options) => {\n    for (const fieldKey in value) {\n      const fieldValue = value[fieldKey];\n      const fieldName = `${name}.${fieldKey}`;\n      const field = get(_fields, fieldName);\n      (_names.array.has(name) || !isPrimitive(fieldValue) || field && !field._f) && !isDateObject(fieldValue) ? setValues(fieldName, fieldValue, options) : setFieldValue(fieldName, fieldValue, options);\n    }\n  };\n  const setValue = function (name, value) {\n    let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n    const field = get(_fields, name);\n    const isFieldArray = _names.array.has(name);\n    const cloneValue = cloneObject(value);\n    set(_formValues, name, cloneValue);\n    if (isFieldArray) {\n      _subjects.array.next({\n        name,\n        values: _formValues\n      });\n      if ((_proxyFormState.isDirty || _proxyFormState.dirtyFields) && options.shouldDirty) {\n        _formState.dirtyFields = getDirtyFields(_defaultValues, _formValues);\n        _subjects.state.next({\n          name,\n          dirtyFields: _formState.dirtyFields,\n          isDirty: _getDirty(name, cloneValue)\n        });\n      }\n    } else {\n      field && !field._f && !isNullOrUndefined(cloneValue) ? setValues(name, cloneValue, options) : setFieldValue(name, cloneValue, options);\n    }\n    isWatched(name, _names) && _subjects.state.next({});\n    _subjects.watch.next({\n      name\n    });\n  };\n  const onChange = async event => {\n    const target = event.target;\n    let name = target.name;\n    const field = get(_fields, name);\n    if (field) {\n      let error;\n      let isValid;\n      const fieldValue = target.type ? getFieldValue(field._f) : getEventValue(event);\n      const isBlurEvent = event.type === EVENTS.BLUR || event.type === EVENTS.FOCUS_OUT;\n      const shouldSkipValidation = !hasValidation(field._f) && !_options.resolver && !get(_formState.errors, name) && !field._f.deps || skipValidation(isBlurEvent, get(_formState.touchedFields, name), _formState.isSubmitted, validationModeAfterSubmit, validationModeBeforeSubmit);\n      const watched = isWatched(name, _names, isBlurEvent);\n      set(_formValues, name, fieldValue);\n      if (isBlurEvent) {\n        field._f.onBlur && field._f.onBlur(event);\n        delayErrorCallback && delayErrorCallback(0);\n      } else if (field._f.onChange) {\n        field._f.onChange(event);\n      }\n      const fieldState = updateTouchAndDirty(name, fieldValue, isBlurEvent, false);\n      const shouldRender = !isEmptyObject(fieldState) || watched;\n      !isBlurEvent && _subjects.watch.next({\n        name,\n        type: event.type\n      });\n      if (shouldSkipValidation) {\n        return shouldRender && _subjects.state.next({\n          name,\n          ...(watched ? {} : fieldState)\n        });\n      }\n      !isBlurEvent && watched && _subjects.state.next({});\n      validateFields[name] = validateFields[name] ? +1 : 1;\n      _subjects.state.next({\n        isValidating: true\n      });\n      if (_options.resolver) {\n        const {\n          errors\n        } = await _executeSchema([name]);\n        const previousErrorLookupResult = schemaErrorLookup(_formState.errors, _fields, name);\n        const errorLookupResult = schemaErrorLookup(errors, _fields, previousErrorLookupResult.name || name);\n        error = errorLookupResult.error;\n        name = errorLookupResult.name;\n        isValid = isEmptyObject(errors);\n      } else {\n        error = (await validateField(field, get(_formValues, name), shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation))[name];\n        isValid = await _updateValid(true);\n      }\n      field._f.deps && trigger(field._f.deps);\n      shouldRenderByError(name, isValid, error, fieldState);\n    }\n  };\n  const trigger = async function (name) {\n    let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n    let isValid;\n    let validationResult;\n    const fieldNames = convertToArrayPayload(name);\n    _subjects.state.next({\n      isValidating: true\n    });\n    if (_options.resolver) {\n      const errors = await executeSchemaAndUpdateState(isUndefined(name) ? name : fieldNames);\n      isValid = isEmptyObject(errors);\n      validationResult = name ? !fieldNames.some(name => get(errors, name)) : isValid;\n    } else if (name) {\n      validationResult = (await Promise.all(fieldNames.map(async fieldName => {\n        const field = get(_fields, fieldName);\n        return await executeBuiltInValidation(field && field._f ? {\n          [fieldName]: field\n        } : field);\n      }))).every(Boolean);\n      !(!validationResult && !_formState.isValid) && _updateValid();\n    } else {\n      validationResult = isValid = await executeBuiltInValidation(_fields);\n    }\n    _subjects.state.next({\n      ...(!isString(name) || _proxyFormState.isValid && isValid !== _formState.isValid ? {} : {\n        name\n      }),\n      ...(_options.resolver || !name ? {\n        isValid\n      } : {}),\n      errors: _formState.errors,\n      isValidating: false\n    });\n    options.shouldFocus && !validationResult && focusFieldBy(_fields, key => key && get(_formState.errors, key), name ? fieldNames : _names.mount);\n    return validationResult;\n  };\n  const getValues = fieldNames => {\n    const values = {\n      ..._defaultValues,\n      ...(_stateFlags.mount ? _formValues : {})\n    };\n    return isUndefined(fieldNames) ? values : isString(fieldNames) ? get(values, fieldNames) : fieldNames.map(name => get(values, name));\n  };\n  const getFieldState = (name, formState) => ({\n    invalid: !!get((formState || _formState).errors, name),\n    isDirty: !!get((formState || _formState).dirtyFields, name),\n    isTouched: !!get((formState || _formState).touchedFields, name),\n    error: get((formState || _formState).errors, name)\n  });\n  const clearErrors = name => {\n    name ? convertToArrayPayload(name).forEach(inputName => unset(_formState.errors, inputName)) : _formState.errors = {};\n    _subjects.state.next({\n      errors: _formState.errors\n    });\n  };\n  const setError = (name, error, options) => {\n    const ref = (get(_fields, name, {\n      _f: {}\n    })._f || {}).ref;\n    set(_formState.errors, name, {\n      ...error,\n      ref\n    });\n    _subjects.state.next({\n      name,\n      errors: _formState.errors,\n      isValid: false\n    });\n    options && options.shouldFocus && ref && ref.focus && ref.focus();\n  };\n  const watch = (name, defaultValue) => isFunction(name) ? _subjects.watch.subscribe({\n    next: info => name(_getWatch(undefined, defaultValue), info)\n  }) : _getWatch(name, defaultValue, true);\n  const unregister = function (name) {\n    let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n    for (const fieldName of name ? convertToArrayPayload(name) : _names.mount) {\n      _names.mount.delete(fieldName);\n      _names.array.delete(fieldName);\n      if (get(_fields, fieldName)) {\n        if (!options.keepValue) {\n          unset(_fields, fieldName);\n          unset(_formValues, fieldName);\n        }\n        !options.keepError && unset(_formState.errors, fieldName);\n        !options.keepDirty && unset(_formState.dirtyFields, fieldName);\n        !options.keepTouched && unset(_formState.touchedFields, fieldName);\n        !_options.shouldUnregister && !options.keepDefaultValue && unset(_defaultValues, fieldName);\n      }\n    }\n    _subjects.watch.next({});\n    _subjects.state.next({\n      ..._formState,\n      ...(!options.keepDirty ? {} : {\n        isDirty: _getDirty()\n      })\n    });\n    !options.keepIsValid && _updateValid();\n  };\n  const register = function (name) {\n    let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n    let field = get(_fields, name);\n    const disabledIsDefined = isBoolean(options.disabled);\n    set(_fields, name, {\n      ...(field || {}),\n      _f: {\n        ...(field && field._f ? field._f : {\n          ref: {\n            name\n          }\n        }),\n        name,\n        mount: true,\n        ...options\n      }\n    });\n    _names.mount.add(name);\n    field ? disabledIsDefined && set(_formValues, name, options.disabled ? undefined : get(_formValues, name, getFieldValue(field._f))) : updateValidAndValue(name, true, options.value);\n    return {\n      ...(disabledIsDefined ? {\n        disabled: options.disabled\n      } : {}),\n      ...(_options.shouldUseNativeValidation ? {\n        required: !!options.required,\n        min: getRuleValue(options.min),\n        max: getRuleValue(options.max),\n        minLength: getRuleValue(options.minLength),\n        maxLength: getRuleValue(options.maxLength),\n        pattern: getRuleValue(options.pattern)\n      } : {}),\n      name,\n      onChange,\n      onBlur: onChange,\n      ref: ref => {\n        if (ref) {\n          register(name, options);\n          field = get(_fields, name);\n          const fieldRef = isUndefined(ref.value) ? ref.querySelectorAll ? ref.querySelectorAll('input,select,textarea')[0] || ref : ref : ref;\n          const radioOrCheckbox = isRadioOrCheckbox(fieldRef);\n          const refs = field._f.refs || [];\n          if (radioOrCheckbox ? refs.find(option => option === fieldRef) : fieldRef === field._f.ref) {\n            return;\n          }\n          set(_fields, name, {\n            _f: {\n              ...field._f,\n              ...(radioOrCheckbox ? {\n                refs: [...refs.filter(live), fieldRef, ...(!!Array.isArray(get(_defaultValues, name)) ? [{}] : [])],\n                ref: {\n                  type: fieldRef.type,\n                  name\n                }\n              } : {\n                ref: fieldRef\n              })\n            }\n          });\n          updateValidAndValue(name, false, undefined, fieldRef);\n        } else {\n          field = get(_fields, name, {});\n          if (field._f) {\n            field._f.mount = false;\n          }\n          (_options.shouldUnregister || options.shouldUnregister) && !(isNameInFieldArray(_names.array, name) && _stateFlags.action) && _names.unMount.add(name);\n        }\n      }\n    };\n  };\n  const _focusError = () => _options.shouldFocusError && focusFieldBy(_fields, key => key && get(_formState.errors, key), _names.mount);\n  const handleSubmit = (onValid, onInvalid) => async e => {\n    if (e) {\n      e.preventDefault && e.preventDefault();\n      e.persist && e.persist();\n    }\n    let hasNoPromiseError = true;\n    let fieldValues = cloneObject(_formValues);\n    _subjects.state.next({\n      isSubmitting: true\n    });\n    try {\n      if (_options.resolver) {\n        const {\n          errors,\n          values\n        } = await _executeSchema();\n        _formState.errors = errors;\n        fieldValues = values;\n      } else {\n        await executeBuiltInValidation(_fields);\n      }\n      if (isEmptyObject(_formState.errors)) {\n        _subjects.state.next({\n          errors: {},\n          isSubmitting: true\n        });\n        await onValid(fieldValues, e);\n      } else {\n        if (onInvalid) {\n          await onInvalid({\n            ..._formState.errors\n          }, e);\n        }\n        _focusError();\n      }\n    } catch (err) {\n      hasNoPromiseError = false;\n      throw err;\n    } finally {\n      _formState.isSubmitted = true;\n      _subjects.state.next({\n        isSubmitted: true,\n        isSubmitting: false,\n        isSubmitSuccessful: isEmptyObject(_formState.errors) && hasNoPromiseError,\n        submitCount: _formState.submitCount + 1,\n        errors: _formState.errors\n      });\n    }\n  };\n  const resetField = function (name) {\n    let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n    if (get(_fields, name)) {\n      if (isUndefined(options.defaultValue)) {\n        setValue(name, get(_defaultValues, name));\n      } else {\n        setValue(name, options.defaultValue);\n        set(_defaultValues, name, options.defaultValue);\n      }\n      if (!options.keepTouched) {\n        unset(_formState.touchedFields, name);\n      }\n      if (!options.keepDirty) {\n        unset(_formState.dirtyFields, name);\n        _formState.isDirty = options.defaultValue ? _getDirty(name, get(_defaultValues, name)) : _getDirty();\n      }\n      if (!options.keepError) {\n        unset(_formState.errors, name);\n        _proxyFormState.isValid && _updateValid();\n      }\n      _subjects.state.next({\n        ..._formState\n      });\n    }\n  };\n  const _reset = function (formValues) {\n    let keepStateOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n    const updatedValues = formValues || _defaultValues;\n    const cloneUpdatedValues = cloneObject(updatedValues);\n    const values = formValues && !isEmptyObject(formValues) ? cloneUpdatedValues : _defaultValues;\n    if (!keepStateOptions.keepDefaultValues) {\n      _defaultValues = updatedValues;\n    }\n    if (!keepStateOptions.keepValues) {\n      if (keepStateOptions.keepDirtyValues) {\n        for (const fieldName of _names.mount) {\n          get(_formState.dirtyFields, fieldName) ? set(values, fieldName, get(_formValues, fieldName)) : setValue(fieldName, get(values, fieldName));\n        }\n      } else {\n        if (isWeb && isUndefined(formValues)) {\n          for (const name of _names.mount) {\n            const field = get(_fields, name);\n            if (field && field._f) {\n              const fieldReference = Array.isArray(field._f.refs) ? field._f.refs[0] : field._f.ref;\n              try {\n                if (isHTMLElement(fieldReference)) {\n                  fieldReference.closest('form').reset();\n                  break;\n                }\n              } catch (_a) {}\n            }\n          }\n        }\n        _fields = {};\n      }\n      _formValues = props.shouldUnregister ? keepStateOptions.keepDefaultValues ? cloneObject(_defaultValues) : {} : cloneUpdatedValues;\n      _subjects.array.next({\n        values\n      });\n      _subjects.watch.next({\n        values\n      });\n    }\n    _names = {\n      mount: new Set(),\n      unMount: new Set(),\n      array: new Set(),\n      watch: new Set(),\n      watchAll: false,\n      focus: ''\n    };\n    _stateFlags.mount = !_proxyFormState.isValid || !!keepStateOptions.keepIsValid;\n    _stateFlags.watch = !!props.shouldUnregister;\n    _subjects.state.next({\n      submitCount: keepStateOptions.keepSubmitCount ? _formState.submitCount : 0,\n      isDirty: keepStateOptions.keepDirty || keepStateOptions.keepDirtyValues ? _formState.isDirty : !!(keepStateOptions.keepDefaultValues && !deepEqual(formValues, _defaultValues)),\n      isSubmitted: keepStateOptions.keepIsSubmitted ? _formState.isSubmitted : false,\n      dirtyFields: keepStateOptions.keepDirty || keepStateOptions.keepDirtyValues ? _formState.dirtyFields : keepStateOptions.keepDefaultValues && formValues ? getDirtyFields(_defaultValues, formValues) : {},\n      touchedFields: keepStateOptions.keepTouched ? _formState.touchedFields : {},\n      errors: keepStateOptions.keepErrors ? _formState.errors : {},\n      isSubmitting: false,\n      isSubmitSuccessful: false\n    });\n  };\n  const reset = (formValues, keepStateOptions) => _reset(isFunction(formValues) ? formValues(_formValues) : formValues, keepStateOptions);\n  const setFocus = function (name) {\n    let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n    const field = get(_fields, name);\n    const fieldReference = field && field._f;\n    if (fieldReference) {\n      const fieldRef = fieldReference.refs ? fieldReference.refs[0] : fieldReference.ref;\n      if (fieldRef.focus) {\n        fieldRef.focus();\n        options.shouldSelect && fieldRef.select();\n      }\n    }\n  };\n  return {\n    control: {\n      register,\n      unregister,\n      getFieldState,\n      _executeSchema,\n      _focusError,\n      _getWatch,\n      _getDirty,\n      _updateValid,\n      _removeUnmounted,\n      _updateFieldArray,\n      _getFieldArray,\n      _subjects,\n      _proxyFormState,\n      get _fields() {\n        return _fields;\n      },\n      get _formValues() {\n        return _formValues;\n      },\n      get _stateFlags() {\n        return _stateFlags;\n      },\n      set _stateFlags(value) {\n        _stateFlags = value;\n      },\n      get _defaultValues() {\n        return _defaultValues;\n      },\n      get _names() {\n        return _names;\n      },\n      set _names(value) {\n        _names = value;\n      },\n      get _formState() {\n        return _formState;\n      },\n      set _formState(value) {\n        _formState = value;\n      },\n      get _options() {\n        return _options;\n      },\n      set _options(value) {\n        _options = {\n          ..._options,\n          ...value\n        };\n      }\n    },\n    trigger,\n    register,\n    handleSubmit,\n    watch,\n    setValue,\n    getValues,\n    reset,\n    resetField,\n    clearErrors,\n    unregister,\n    setError,\n    setFocus,\n    getFieldState\n  };\n}\n\n/**\r\n * Custom hook to manage the entire form.\r\n *\r\n * @remarks\r\n * [API](https://react-hook-form.com/api/useform) • [Demo](https://codesandbox.io/s/react-hook-form-get-started-ts-5ksmm) • [Video](https://www.youtube.com/watch?v=RkXv4AXXC_4)\r\n *\r\n * @param props - form configuration and validation parameters.\r\n *\r\n * @returns methods - individual functions to manage the form state. {@link UseFormReturn}\r\n *\r\n * @example\r\n * ```tsx\r\n * function App() {\r\n *   const { register, handleSubmit, watch, formState: { errors } } = useForm();\r\n *   const onSubmit = data => console.log(data);\r\n *\r\n *   console.log(watch(\"example\"));\r\n *\r\n *   return (\r\n *     <form onSubmit={handleSubmit(onSubmit)}>\r\n *       <input defaultValue=\"test\" {...register(\"example\")} />\r\n *       <input {...register(\"exampleRequired\", { required: true })} />\r\n *       {errors.exampleRequired && <span>This field is required</span>}\r\n *       <input type=\"submit\" />\r\n *     </form>\r\n *   );\r\n * }\r\n * ```\r\n */\nfunction useForm() {\n  let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n  const _formControl = React.useRef();\n  const [formState, updateFormState] = React.useState({\n    isDirty: false,\n    isValidating: false,\n    isSubmitted: false,\n    isSubmitting: false,\n    isSubmitSuccessful: false,\n    isValid: false,\n    submitCount: 0,\n    dirtyFields: {},\n    touchedFields: {},\n    errors: {},\n    defaultValues: props.defaultValues\n  });\n  if (!_formControl.current) {\n    _formControl.current = {\n      ...createFormControl(props),\n      formState\n    };\n  }\n  const control = _formControl.current.control;\n  control._options = props;\n  useSubscribe({\n    subject: control._subjects.state,\n    callback: React.useCallback(value => {\n      if (shouldRenderFormState(value, control._proxyFormState, true)) {\n        control._formState = {\n          ...control._formState,\n          ...value\n        };\n        updateFormState({\n          ...control._formState\n        });\n      }\n    }, [control])\n  });\n  React.useEffect(() => {\n    if (!control._stateFlags.mount) {\n      control._proxyFormState.isValid && control._updateValid();\n      control._stateFlags.mount = true;\n    }\n    if (control._stateFlags.watch) {\n      control._stateFlags.watch = false;\n      control._subjects.state.next({});\n    }\n    control._removeUnmounted();\n  });\n  React.useEffect(() => {\n    formState.submitCount && control._focusError();\n  }, [control, formState.submitCount]);\n  _formControl.current.formState = getProxyFormState(formState, control);\n  return _formControl.current;\n}\nexport { Controller, FormProvider, appendErrors, get, set, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch };","map":{"version":3,"mappings":";AAEA,sBAAgBA,OAAqB,IACnCA,OAAO,CAACC,IAAI,KAAK,UAAU;ACH7B,mBAAgBC,KAAc,IAAoBA,KAAK,YAAYC,IAAI;ACAvE,wBAAgBD,KAAc,IAAgCA,KAAK,IAAI,IAAI;ACGpE,MAAME,YAAY,GAAIF,KAAc,IAAK,OAAOA,KAAK,KAAK,QAAQ;AAEzE,eAAkCA,KAAc,IAC9C,CAACG,iBAAiB,CAACH,KAAK,CAAC,IACzB,CAACI,KAAK,CAACC,OAAO,CAACL,KAAK,CAAC,IACrBE,YAAY,CAACF,KAAK,CAAC,IACnB,CAACM,YAAY,CAACN,KAAK,CAAC;ACJtB,oBAAgBO,KAAc,IAC5BC,QAAQ,CAACD,KAAK,CAAC,IAAKA,KAAe,CAACE,MAAM,GACtCC,eAAe,CAAEH,KAAe,CAACE,MAAM,CAAC,GACrCF,KAAe,CAACE,MAAM,CAACE,OAAO,GAC9BJ,KAAe,CAACE,MAAM,CAACT,KAAK,GAC/BO,KAAK;ACVX,wBAAgBK,IAAY,IAC1BA,IAAI,CAACC,SAAS,CAAC,CAAC,EAAED,IAAI,CAACE,MAAM,CAAC,aAAa,CAAC,CAAC,IAAIF,IAAI;ACGvD,yBAAe,CAACG,KAA6B,EAAEH,IAAuB,KACpEG,KAAK,CAACC,GAAG,CAACC,iBAAiB,CAACL,IAAI,CAAC,CAAC;ACLpC,cAAwBZ,KAAe,IACrCI,KAAK,CAACC,OAAO,CAACL,KAAK,CAAC,GAAGA,KAAK,CAACkB,MAAM,CAACC,OAAO,CAAC,GAAG,EAAE;ACDnD,kBAAgBC,GAAY,IAAuBA,GAAG,KAAKC,SAAS;ACKpE,UAAe,CA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,KAAK,EAAE;MAC7BzD,OAAO,CAACuF,WAAW,CAAC9B,KAAK,GAAG,KAAK;MACjCzD,OAAO,CAACkD,SAAS,CAACC,KAAK,CAACrB,IAAI,CAAC,EAAE,CAAC;IACjC;IAED9B,OAAO,CAACuE,gBAAgB,EAAE;EAC5B,CAAC,CAAC;EAEFhF,KAAK,CAACkC,SAAS,CAAC,MAAK;IACnB1B,SAAS,CAACsU,WAAW,IAAIrU,OAAO,CAACma,WAAW,EAAE;GAC/C,EAAE,CAACna,OAAO,EAAED,SAAS,CAACsU,WAAW,CAAC,CAAC;EAEpCsH,YAAY,CAACna,OAAO,CAACzB,SAAS,GAAGqD,iBAAiB,CAACrD,SAAS,EAAEC,OAAO,CAAC;EAEtE,OAAO2b,YAAY,CAACna,OAAO;AAC7B","names":["element","type","value","Date","isObjectType","isNullOrUndefined","Array","isArray","isDateObject","event","isObject","target","isCheckBoxInput","checked","name","substring","search","names","has","getNodeParentName","filter","Boolean","val","undefined","obj","path","defaultValue","result","compact","split","reduce","key","isUndefined","EVENTS","BLUR","FOCUS_OUT","CHANGE","VALIDATION_MODE","onBlur","onChange","onSubmit","onTouched","all","INPUT_VALIDATION_RULES","max","min","maxLength","minLength","pattern","required","validate","HookFormContext","React","createContext","useFormContext","useContext","props","children","data","Provider","formState","control","localProxyFormState","isRoot","defaultValues","_defaultValues","Object","defineProperty","get","_key","_proxyFormState","keys","length","formStateData","isEmptyObject","find","signalName","exact","convertToArrayPayload","some","currentName","startsWith","useSubscribe","_props","useRef","current","useEffect","subscription","disabled","subject","subscribe","next","callback","unsubscribe","useFormState","methods","updateFormState","useState","_formState","_mounted","_localProxyFormState","isDirty","dirtyFields","touchedFields","isValidating","isValid","errors","_name","useCallback","shouldSubscribeByName","shouldRenderFormState","_subjects","state","getProxyFormState","_names","formValues","isGlobal","isString","watch","add","map","fieldName","watchAll","isFunction","useWatch","fieldValues","generateWatchOutput","values","_formValues","updateValue","objectHasFunction","_getWatch","_removeUnmounted","useController","shouldUnregister","isArrayField","isNameInFieldArray","array","_registerProps","register","rules","updateMounted","field","_fields","_f","mount","_shouldUnregisterField","_options","_stateFlags","action","unregister","getEventValue","ref","elm","focus","select","setCustomValidity","message","reportValidity","fieldState","defineProperties","invalid","enumerable","isTouched","error","Controller","render","validateAllFieldCriteria","types","test","input","replace","object","index","tempPath","isKey","stringToPath","lastIndex","newValue","objValue","isNaN","focusFieldBy","fields","fieldsNames","currentField","refs","d","performance","now","c","r","Math","random","toString","options","shouldFocus","focusName","focusIndex","isBlurEvent","watchName","slice","fieldArrayErrors","set","isValidElement","RegExp","defaultResult","validResult","option","attributes","defaultReturn","previous","getValidateError","isMessage","every","isBoolean","validationData","isRegex","inputValue","shouldUseNativeValidation","isFieldArray","valueAsNumber","inputRef","isRadio","isRadioInput","isCheckBox","isRadioOrCheckbox","isEmpty","isFileInput","appendErrorsCurry","appendErrors","bind","getMinMaxMessage","exceedMax","maxLengthMessage","minLengthMessage","maxType","minType","getCheckboxValue","getRadioValue","getValueAndMessage","exceedMin","maxOutput","minOutput","valueNumber","valueDate","valueAsDate","convertTimeToDate","time","toDateString","isTime","isWeek","maxLengthOutput","minLengthOutput","patternValue","match","validateError","validationResult","append","tempObject","prototypeCopy","constructor","prototype","hasOwnProperty","window","HTMLElement","document","copy","Set","isWeb","Blob","FileList","isPlainObject","cloneObject","mode","isOnSubmit","isOnBlur","isOnChange","isOnAll","isOnTouch","from","to","splice","prepend","removeAtIndexes","indexes","i","temp","sort","a","b","indexA","indexB","baseGet","updatePath","isEmptyArray","unset","childObject","previousObjRef","k","objectRef","currentPaths","currentPathsLength","item","useFieldArray","keyName","setFields","_getFieldArray","ids","generateId","_fieldIds","_actioned","fieldArrayName","updateValues","updatedFieldArrayValues","_updateFieldArray","appendValue","appendAt","getFocusFieldName","argA","fillEmptyArray","prependValue","prependAt","remove","removeArrayAt","insert","insertValue","insertAt","argB","swap","swapArrayAt","move","moveArrayAt","update","updateAt","isWatched","getValidationModes","isSubmitted","resolver","_executeSchema","then","existingError","validateField","criteriaMode","updateFieldArrayRootError","_updateValid","useMemo","createSubject","_observers","observer","push","o","observers","deepEqual","object1","object2","isPrimitive","getTime","keys1","keys2","val1","includes","val2","owner","ownerDocument","ElementClass","defaultView","isHTMLElement","isConnected","markFieldsDirty","isParentNodeArray","getDirtyFieldsFromDefaultValues","dirtyFieldsFromValues","setValueAs","NaN","files","isMultipleSelect","selectedOptions","getFieldValueAs","rule","source","join","foundError","pop","reValidateMode","defaultOptions","shouldFocusError","submitCount","isSubmitting","isSubmitSuccessful","unMount","delayErrorCallback","timer","validateFields","validationModeBeforeSubmit","validationModeAfterSubmit","shouldDisplayAllAssociatedErrors","debounce","wait","clearTimeout","setTimeout","shouldSkipRender","executeBuiltInValidation","method","args","shouldSetValues","shouldUpdateFieldsAndState","unsetEmptyArray","getDirtyFields","_getDirty","updateErrors","updateValidAndValue","shouldSkipSetValueAs","defaultChecked","getFieldValue","setFieldValue","updateTouchAndDirty","fieldValue","shouldDirty","shouldRender","isFieldDirty","output","isPreviousFieldTouched","isPreviousFormDirty","isPreviousFieldDirty","isCurrentFieldPristine","shouldRenderByError","previousFieldError","shouldUpdateValid","delayError","updatedFormState","v","context","getResolverOptions","executeSchemaAndUpdateState","shouldOnlyCheckValid","valid","isFieldArrayRoot","fieldError","live","getValues","fieldReference","forEach","optionRef","selected","checkboxRef","radioRef","shouldTouch","shouldValidate","trigger","setValues","fieldKey","setValue","cloneValue","shouldSkipValidation","hasValidation","deps","skipValidation","watched","previousErrorLookupResult","schemaErrorLookup","errorLookupResult","fieldNames","Promise","getFieldState","clearErrors","inputName","setError","info","delete","keepValue","keepError","keepDirty","keepTouched","keepDefaultValue","keepIsValid","disabledIsDefined","getRuleValue","fieldRef","querySelectorAll","radioOrCheckbox","_focusError","handleSubmit","onValid","onInvalid","e","preventDefault","persist","hasNoPromiseError","err","resetField","_reset","keepStateOptions","updatedValues","cloneUpdatedValues","keepDefaultValues","keepValues","keepDirtyValues","closest","reset","keepSubmitCount","keepIsSubmitted","keepErrors","setFocus","shouldSelect","_formControl","createFormControl"],"sources":["/data/messenger.client/node_modules/react-hook-form/src/utils/isCheckBoxInput.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isDateObject.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isNullOrUndefined.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isObject.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/getEventValue.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/getNodeParentName.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/isNameInFieldArray.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/compact.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isUndefined.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/get.ts","/data/messenger.client/node_modules/react-hook-form/src/constants.ts","/data/messenger.client/node_modules/react-hook-form/src/useFormContext.tsx","/data/messenger.client/node_modules/react-hook-form/src/logic/getProxyFormState.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isEmptyObject.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/shouldRenderFormState.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/convertToArrayPayload.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/shouldSubscribeByName.ts","/data/messenger.client/node_modules/react-hook-form/src/useSubscribe.ts","/data/messenger.client/node_modules/react-hook-form/src/useFormState.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isString.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/generateWatchOutput.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isFunction.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/objectHasFunction.ts","/data/messenger.client/node_modules/react-hook-form/src/useWatch.ts","/data/messenger.client/node_modules/react-hook-form/src/useController.ts","/data/messenger.client/node_modules/react-hook-form/src/controller.tsx","/data/messenger.client/node_modules/react-hook-form/src/logic/appendErrors.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isKey.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/stringToPath.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/set.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/focusFieldBy.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/generateId.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/getFocusFieldName.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/isWatched.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/updateFieldArrayRootError.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isBoolean.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isFileInput.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isMessage.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isRadioInput.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isRegex.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/getCheckboxValue.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/getRadioValue.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/getValidateError.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/getValueAndMessage.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/validateField.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/append.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isPlainObject.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isWeb.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/cloneObject.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/fillEmptyArray.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/getValidationModes.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/insert.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/move.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/prepend.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/remove.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/swap.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/unset.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/update.ts","/data/messenger.client/node_modules/react-hook-form/src/useFieldArray.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/createSubject.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isPrimitive.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/deepEqual.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isHTMLElement.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isMultipleSelect.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/isRadioOrCheckbox.ts","/data/messenger.client/node_modules/react-hook-form/src/utils/live.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/getDirtyFields.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/getFieldValueAs.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/getFieldValue.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/getResolverOptions.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/getRuleValue.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/hasValidation.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/schemaErrorLookup.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/skipValidation.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/unsetEmptyArray.ts","/data/messenger.client/node_modules/react-hook-form/src/logic/createFormControl.ts","/data/messenger.client/node_modules/react-hook-form/src/useForm.ts"],"sourcesContent":["import { FieldElement } from '../types';\n\nexport default (element: FieldElement): element is HTMLInputElement =>\n  element.type === 'checkbox';\n","export default (value: unknown): value is Date => value instanceof Date;\n","export default (value: unknown): value is null | undefined => value == null;\n","import isDateObject from './isDateObject';\nimport isNullOrUndefined from './isNullOrUndefined';\n\nexport const isObjectType = (value: unknown) => typeof value === 'object';\n\nexport default <T extends object>(value: unknown): value is T =>\n  !isNullOrUndefined(value) &&\n  !Array.isArray(value) &&\n  isObjectType(value) &&\n  !isDateObject(value);\n","import isCheckBoxInput from '../utils/isCheckBoxInput';\nimport isObject from '../utils/isObject';\n\ntype Event = { target: any };\n\nexport default (event: unknown) =>\n  isObject(event) && (event as Event).target\n    ? isCheckBoxInput((event as Event).target)\n      ? (event as Event).target.checked\n      : (event as Event).target.value\n    : event;\n","export default (name: string) =>\n  name.substring(0, name.search(/\\.\\d+(\\.|$)/)) || name;\n","import { InternalFieldName } from '../types';\n\nimport getNodeParentName from './getNodeParentName';\n\nexport default (names: Set<InternalFieldName>, name: InternalFieldName) =>\n  names.has(getNodeParentName(name));\n","export default <TValue>(value: TValue[]) =>\n  Array.isArray(value) ? value.filter(Boolean) : [];\n","export default (val: unknown): val is undefined => val === undefined;\n","import compact from './compact';\nimport isNullOrUndefined from './isNullOrUndefined';\nimport isObject from './isObject';\nimport isUndefined from './isUndefined';\n\nexport default <T>(obj: T, path: string, defaultValue?: unknown): any => {\n  if (!path || !isObject(obj)) {\n    return defaultValue;\n  }\n\n  const result = compact(path.split(/[,[\\].]+?/)).reduce(\n    (result, key) =>\n      isNullOrUndefined(result) ? result : result[key as keyof {}],\n    obj,\n  );\n\n  return isUndefined(result) || result === obj\n    ? isUndefined(obj[path as keyof T])\n      ? defaultValue\n      : obj[path as keyof T]\n    : result;\n};\n","import { ValidationMode } from './types';\n\nexport const EVENTS = {\n  BLUR: 'blur',\n  FOCUS_OUT: 'focusout',\n  CHANGE: 'change',\n};\n\nexport const VALIDATION_MODE: ValidationMode = {\n  onBlur: 'onBlur',\n  onChange: 'onChange',\n  onSubmit: 'onSubmit',\n  onTouched: 'onTouched',\n  all: 'all',\n};\n\nexport const INPUT_VALIDATION_RULES = {\n  max: 'max',\n  min: 'min',\n  maxLength: 'maxLength',\n  minLength: 'minLength',\n  pattern: 'pattern',\n  required: 'required',\n  validate: 'validate',\n};\n","import React from 'react';\n\nimport { FieldValues, FormProviderProps, UseFormReturn } from './types';\n\nconst HookFormContext = React.createContext<UseFormReturn | null>(null);\n\n/**\n * This custom hook allows you to access the form context. useFormContext is intended to be used in deeply nested structures, where it would become inconvenient to pass the context as a prop. To be used with {@link FormProvider}.\n *\n * @remarks\n * [API](https://react-hook-form.com/api/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)\n *\n * @returns return all useForm methods\n *\n * @example\n * ```tsx\n * function App() {\n *   const methods = useForm();\n *   const onSubmit = data => console.log(data);\n *\n *   return (\n *     <FormProvider {...methods} >\n *       <form onSubmit={methods.handleSubmit(onSubmit)}>\n *         <NestedInput />\n *         <input type=\"submit\" />\n *       </form>\n *     </FormProvider>\n *   );\n * }\n *\n *  function NestedInput() {\n *   const { register } = useFormContext(); // retrieve all hook methods\n *   return <input {...register(\"test\")} />;\n * }\n * ```\n */\nexport const useFormContext = <\n  TFieldValues extends FieldValues,\n>(): UseFormReturn<TFieldValues> =>\n  React.useContext(HookFormContext) as unknown as UseFormReturn<TFieldValues>;\n\n/**\n * A provider component that propagates the `useForm` methods to all children components via [React Context](https://reactjs.org/docs/context.html) API. To be used with {@link useFormContext}.\n *\n * @remarks\n * [API](https://react-hook-form.com/api/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)\n *\n * @param props - all useFrom methods\n *\n * @example\n * ```tsx\n * function App() {\n *   const methods = useForm();\n *   const onSubmit = data => console.log(data);\n *\n *   return (\n *     <FormProvider {...methods} >\n *       <form onSubmit={methods.handleSubmit(onSubmit)}>\n *         <NestedInput />\n *         <input type=\"submit\" />\n *       </form>\n *     </FormProvider>\n *   );\n * }\n *\n *  function NestedInput() {\n *   const { register } = useFormContext(); // retrieve all hook methods\n *   return <input {...register(\"test\")} />;\n * }\n * ```\n */\nexport const FormProvider = <TFieldValues extends FieldValues, TContext = any>(\n  props: FormProviderProps<TFieldValues, TContext>,\n) => {\n  const { children, ...data } = props;\n  return (\n    <HookFormContext.Provider value={data as unknown as UseFormReturn}>\n      {children}\n    </HookFormContext.Provider>\n  );\n};\n","import { VALIDATION_MODE } from '../constants';\nimport { Control, FieldValues, FormState, ReadFormState } from '../types';\n\nexport default <TFieldValues extends FieldValues>(\n  formState: FormState<TFieldValues>,\n  control: Control<TFieldValues>,\n  localProxyFormState?: ReadFormState,\n  isRoot = true,\n) => {\n  const result = {\n    defaultValues: control._defaultValues,\n  } as typeof formState;\n\n  for (const key in formState) {\n    Object.defineProperty(result, key, {\n      get: () => {\n        const _key = key as keyof FormState<TFieldValues> & keyof ReadFormState;\n\n        if (control._proxyFormState[_key] !== VALIDATION_MODE.all) {\n          control._proxyFormState[_key] = !isRoot || VALIDATION_MODE.all;\n        }\n\n        localProxyFormState && (localProxyFormState[_key] = true);\n        return formState[_key];\n      },\n    });\n  }\n\n  return result;\n};\n","import { EmptyObject } from '../types';\n\nimport isObject from './isObject';\n\nexport default (value: unknown): value is EmptyObject =>\n  isObject(value) && !Object.keys(value).length;\n","import { VALIDATION_MODE } from '../constants';\nimport { ReadFormState } from '../types';\nimport isEmptyObject from '../utils/isEmptyObject';\n\nexport default <T extends Record<string, any>, K extends ReadFormState>(\n  formStateData: T,\n  _proxyFormState: K,\n  isRoot?: boolean,\n) => {\n  const { name, ...formState } = formStateData;\n\n  return (\n    isEmptyObject(formState) ||\n    Object.keys(formState).length >= Object.keys(_proxyFormState).length ||\n    Object.keys(formState).find(\n      (key) =>\n        _proxyFormState[key as keyof ReadFormState] ===\n        (!isRoot || VALIDATION_MODE.all),\n    )\n  );\n};\n","export default <T>(value: T) => (Array.isArray(value) ? value : [value]);\n","import convertToArrayPayload from '../utils/convertToArrayPayload';\n\nexport default <T extends string | string[] | undefined>(\n  name?: T,\n  signalName?: string,\n  exact?: boolean,\n) =>\n  exact && signalName\n    ? name === signalName\n    : !name ||\n      !signalName ||\n      name === signalName ||\n      convertToArrayPayload(name).some(\n        (currentName) =>\n          currentName &&\n          (currentName.startsWith(signalName) ||\n            signalName.startsWith(currentName)),\n      );\n","import React from 'react';\n\nimport { Subject } from './utils/createSubject';\n\ntype Props<T> = {\n  disabled?: boolean;\n  subject: Subject<T>;\n  callback: (value: T) => void;\n};\n\nexport function useSubscribe<T>(props: Props<T>) {\n  const _props = React.useRef(props);\n  _props.current = props;\n\n  React.useEffect(() => {\n    const subscription =\n      !props.disabled &&\n      _props.current.subject.subscribe({\n        next: _props.current.callback,\n      });\n\n    return () => {\n      subscription && subscription.unsubscribe();\n    };\n  }, [props.disabled]);\n}\n","import React from 'react';\n\nimport getProxyFormState from './logic/getProxyFormState';\nimport shouldRenderFormState from './logic/shouldRenderFormState';\nimport shouldSubscribeByName from './logic/shouldSubscribeByName';\nimport {\n  FieldValues,\n  InternalFieldName,\n  UseFormStateProps,\n  UseFormStateReturn,\n} from './types';\nimport { useFormContext } from './useFormContext';\nimport { useSubscribe } from './useSubscribe';\n\n/**\n * This custom hook allows you to subscribe to each form state, and isolate the re-render at the custom hook level. It has its scope in terms of form state subscription, so it would not affect other useFormState and useForm. Using this hook can reduce the re-render impact on large and complex form application.\n *\n * @remarks\n * [API](https://react-hook-form.com/api/useformstate) • [Demo](https://codesandbox.io/s/useformstate-75xly)\n *\n * @param props - include options on specify fields to subscribe. {@link UseFormStateReturn}\n *\n * @example\n * ```tsx\n * function App() {\n *   const { register, handleSubmit, control } = useForm({\n *     defaultValues: {\n *     firstName: \"firstName\"\n *   }});\n *   const { dirtyFields } = useFormState({\n *     control\n *   });\n *   const onSubmit = (data) => console.log(data);\n *\n *   return (\n *     <form onSubmit={handleSubmit(onSubmit)}>\n *       <input {...register(\"firstName\")} placeholder=\"First Name\" />\n *       {dirtyFields.firstName && <p>Field is dirty.</p>}\n *       <input type=\"submit\" />\n *     </form>\n *   );\n * }\n * ```\n */\nfunction useFormState<TFieldValues extends FieldValues = FieldValues>(\n  props?: UseFormStateProps<TFieldValues>,\n): UseFormStateReturn<TFieldValues> {\n  const methods = useFormContext<TFieldValues>();\n  const { control = methods.control, disabled, name, exact } = props || {};\n  const [formState, updateFormState] = React.useState(control._formState);\n  const _mounted = React.useRef(true);\n  const _localProxyFormState = React.useRef({\n    isDirty: false,\n    dirtyFields: false,\n    touchedFields: false,\n    isValidating: false,\n    isValid: false,\n    errors: false,\n  });\n  const _name = React.useRef(name);\n\n  _name.current = name;\n\n  useSubscribe({\n    disabled,\n    callback: React.useCallback(\n      (value: { name?: InternalFieldName }) =>\n        _mounted.current &&\n        shouldSubscribeByName(\n          _name.current as InternalFieldName,\n          value.name,\n          exact,\n        ) &&\n        shouldRenderFormState(value, _localProxyFormState.current) &&\n        updateFormState({\n          ...control._formState,\n          ...value,\n        }),\n      [control, exact],\n    ),\n    subject: control._subjects.state,\n  });\n\n  React.useEffect(() => {\n    _mounted.current = true;\n    return () => {\n      _mounted.current = false;\n    };\n  }, []);\n\n  return getProxyFormState(\n    formState,\n    control,\n    _localProxyFormState.current,\n    false,\n  );\n}\n\nexport { useFormState };\n","export default (value: unknown): value is string => typeof value === 'string';\n","import { FieldValues, InternalFieldName, Names } from '../types';\nimport get from '../utils/get';\nimport isString from '../utils/isString';\n\nexport default (\n  names: string | string[] | undefined,\n  _names: Names,\n  formValues?: FieldValues,\n  isGlobal?: boolean,\n) => {\n  const isArray = Array.isArray(names);\n  if (isString(names)) {\n    isGlobal && _names.watch.add(names as InternalFieldName);\n    return get(formValues, names as InternalFieldName);\n  }\n\n  if (isArray) {\n    return names.map(\n      (fieldName) => (\n        isGlobal && _names.watch.add(fieldName as InternalFieldName),\n        get(formValues, fieldName as InternalFieldName)\n      ),\n    );\n  }\n\n  isGlobal && (_names.watchAll = true);\n  return formValues;\n};\n","export default (value: unknown): value is Function =>\n  typeof value === 'function';\n","import isFunction from './isFunction';\n\nexport default <T>(data: T): boolean => {\n  for (const key in data) {\n    if (isFunction(data[key])) {\n      return true;\n    }\n  }\n  return false;\n};\n","import React from 'react';\n\nimport generateWatchOutput from './logic/generateWatchOutput';\nimport shouldSubscribeByName from './logic/shouldSubscribeByName';\nimport isObject from './utils/isObject';\nimport isUndefined from './utils/isUndefined';\nimport objectHasFunction from './utils/objectHasFunction';\nimport {\n  Control,\n  DeepPartialSkipArrayKey,\n  FieldPath,\n  FieldPathValue,\n  FieldPathValues,\n  FieldValues,\n  InternalFieldName,\n  UseWatchProps,\n} from './types';\nimport { useFormContext } from './useFormContext';\nimport { useSubscribe } from './useSubscribe';\n\n/**\n * Subscribe to the entire form values change and re-render at the hook level.\n *\n * @remarks\n *\n * [API](https://react-hook-form.com/api/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)\n *\n * @param props - defaultValue, disable subscription and match exact name.\n *\n * @example\n * ```tsx\n * const { watch } = useForm();\n * const values = useWatch({\n *   control,\n *   defaultValue: {\n *     name: \"data\"\n *   },\n *   exact: false,\n * })\n * ```\n */\nexport function useWatch<\n  TFieldValues extends FieldValues = FieldValues,\n>(props: {\n  defaultValue?: DeepPartialSkipArrayKey<TFieldValues>;\n  control?: Control<TFieldValues>;\n  disabled?: boolean;\n  exact?: boolean;\n}): DeepPartialSkipArrayKey<TFieldValues>;\n/**\n * Custom hook to subscribe to field change and isolate re-rendering at the component level.\n *\n * @remarks\n *\n * [API](https://react-hook-form.com/api/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)\n *\n * @param props - defaultValue, disable subscription and match exact name.\n *\n * @example\n * ```tsx\n * const { watch } = useForm();\n * const values = useWatch({\n *   control,\n *   name: \"fieldA\",\n *   defaultValue: \"default value\",\n *   exact: false,\n * })\n * ```\n */\nexport function useWatch<\n  TFieldValues extends FieldValues = FieldValues,\n  TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>(props: {\n  name: TFieldName;\n  defaultValue?: FieldPathValue<TFieldValues, TFieldName>;\n  control?: Control<TFieldValues>;\n  disabled?: boolean;\n  exact?: boolean;\n}): FieldPathValue<TFieldValues, TFieldName>;\n/**\n * Custom hook to subscribe to field change and isolate re-rendering at the component level.\n *\n * @remarks\n *\n * [API](https://react-hook-form.com/api/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)\n *\n * @param props - defaultValue, disable subscription and match exact name.\n *\n * @example\n * ```tsx\n * const { watch } = useForm();\n * const values = useWatch({\n *   control,\n *   name: [\"fieldA\", \"fieldB\"],\n *   defaultValue: {\n *     fieldA: \"data\",\n *     fieldB: \"data\"\n *   },\n *   exact: false,\n * })\n * ```\n */\nexport function useWatch<\n  TFieldValues extends FieldValues = FieldValues,\n  TFieldNames extends readonly FieldPath<TFieldValues>[] = readonly FieldPath<TFieldValues>[],\n>(props: {\n  name: readonly [...TFieldNames];\n  defaultValue?: DeepPartialSkipArrayKey<TFieldValues>;\n  control?: Control<TFieldValues>;\n  disabled?: boolean;\n  exact?: boolean;\n}): FieldPathValues<TFieldValues, TFieldNames>;\n/**\n * Custom hook to subscribe to field change and isolate re-rendering at the component level.\n *\n * @remarks\n *\n * [API](https://react-hook-form.com/api/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)\n *\n * @example\n * ```tsx\n * // can skip passing down the control into useWatch if the form is wrapped with the FormProvider\n * const values = useWatch()\n * ```\n */\nexport function useWatch<\n  TFieldValues extends FieldValues = FieldValues,\n>(): DeepPartialSkipArrayKey<TFieldValues>;\n/**\n * Custom hook to subscribe to field change and isolate re-rendering at the component level.\n *\n * @remarks\n *\n * [API](https://react-hook-form.com/api/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)\n *\n * @example\n * ```tsx\n * const { watch } = useForm();\n * const values = useWatch({\n *   name: \"fieldName\"\n *   control,\n * })\n * ```\n */\nexport function useWatch<TFieldValues extends FieldValues>(\n  props?: UseWatchProps<TFieldValues>,\n) {\n  const methods = useFormContext();\n  const {\n    control = methods.control,\n    name,\n    defaultValue,\n    disabled,\n    exact,\n  } = props || {};\n  const _name = React.useRef(name);\n\n  _name.current = name;\n\n  useSubscribe({\n    disabled,\n    subject: control._subjects.watch,\n    callback: React.useCallback(\n      (formState: { name?: InternalFieldName; values?: FieldValues }) => {\n        if (\n          shouldSubscribeByName(\n            _name.current as InternalFieldName,\n            formState.name,\n            exact,\n          )\n        ) {\n          const fieldValues = generateWatchOutput(\n            _name.current as InternalFieldName | InternalFieldName[],\n            control._names,\n            formState.values || control._formValues,\n          );\n\n          updateValue(\n            isUndefined(_name.current) ||\n              (isObject(fieldValues) && !objectHasFunction(fieldValues))\n              ? { ...fieldValues }\n              : Array.isArray(fieldValues)\n              ? [...fieldValues]\n              : isUndefined(fieldValues)\n              ? defaultValue\n              : fieldValues,\n          );\n        }\n      },\n      [control, exact, defaultValue],\n    ),\n  });\n\n  const [value, updateValue] = React.useState<unknown>(\n    isUndefined(defaultValue)\n      ? control._getWatch(name as InternalFieldName)\n      : defaultValue,\n  );\n\n  React.useEffect(() => control._removeUnmounted());\n\n  return value;\n}\n","import React from 'react';\n\nimport getEventValue from './logic/getEventValue';\nimport isNameInFieldArray from './logic/isNameInFieldArray';\nimport get from './utils/get';\nimport { EVENTS } from './constants';\nimport {\n  ControllerFieldState,\n  Field,\n  FieldPath,\n  FieldPathValue,\n  FieldValues,\n  InternalFieldName,\n  UseControllerProps,\n  UseControllerReturn,\n} from './types';\nimport { useFormContext } from './useFormContext';\nimport { useFormState } from './useFormState';\nimport { useWatch } from './useWatch';\n\n/**\n * Custom hook to work with controlled component, this function provide you with both form and field level state. Re-render is isolated at the hook level.\n *\n * @remarks\n * [API](https://react-hook-form.com/api/usecontroller) • [Demo](https://codesandbox.io/s/usecontroller-0o8px)\n *\n * @param props - the path name to the form field value, and validation rules.\n *\n * @returns field properties, field and form state. {@link UseControllerReturn}\n *\n * @example\n * ```tsx\n * function Input(props) {\n *   const { field, fieldState, formState } = useController(props);\n *   return (\n *     <div>\n *       <input {...field} placeholder={props.name} />\n *       <p>{fieldState.isTouched && \"Touched\"}</p>\n *       <p>{formState.isSubmitted ? \"submitted\" : \"\"}</p>\n *     </div>\n *   );\n * }\n * ```\n */\nexport function useController<\n  TFieldValues extends FieldValues = FieldValues,\n  TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>(\n  props: UseControllerProps<TFieldValues, TName>,\n): UseControllerReturn<TFieldValues, TName> {\n  const methods = useFormContext<TFieldValues>();\n  const { name, control = methods.control, shouldUnregister } = props;\n  const isArrayField = isNameInFieldArray(control._names.array, name);\n  const value = useWatch({\n    control,\n    name,\n    defaultValue: get(\n      control._formValues,\n      name,\n      get(control._defaultValues, name, props.defaultValue),\n    ),\n    exact: true,\n  }) as FieldPathValue<TFieldValues, TName>;\n  const formState = useFormState({\n    control,\n    name,\n  });\n\n  const _registerProps = React.useRef(\n    control.register(name, {\n      ...props.rules,\n      value,\n    }),\n  );\n\n  React.useEffect(() => {\n    const updateMounted = (name: InternalFieldName, value: boolean) => {\n      const field: Field = get(control._fields, name);\n\n      if (field) {\n        field._f.mount = value;\n      }\n    };\n\n    updateMounted(name, true);\n\n    return () => {\n      const _shouldUnregisterField =\n        control._options.shouldUnregister || shouldUnregister;\n\n      (\n        isArrayField\n          ? _shouldUnregisterField && !control._stateFlags.action\n          : _shouldUnregisterField\n      )\n        ? control.unregister(name)\n        : updateMounted(name, false);\n    };\n  }, [name, control, isArrayField, shouldUnregister]);\n\n  return {\n    field: {\n      name,\n      value,\n      onChange: React.useCallback(\n        (event) =>\n          _registerProps.current.onChange({\n            target: {\n              value: getEventValue(event),\n              name: name as InternalFieldName,\n            },\n            type: EVENTS.CHANGE,\n          }),\n        [name],\n      ),\n      onBlur: React.useCallback(\n        () =>\n          _registerProps.current.onBlur({\n            target: {\n              value: get(control._formValues, name),\n              name: name as InternalFieldName,\n            },\n            type: EVENTS.BLUR,\n          }),\n        [name, control],\n      ),\n      ref: (elm) => {\n        const field = get(control._fields, name);\n\n        if (field && elm) {\n          field._f.ref = {\n            focus: () => elm.focus(),\n            select: () => elm.select(),\n            setCustomValidity: (message: string) =>\n              elm.setCustomValidity(message),\n            reportValidity: () => elm.reportValidity(),\n          };\n        }\n      },\n    },\n    formState,\n    fieldState: Object.defineProperties(\n      {},\n      {\n        invalid: {\n          enumerable: true,\n          get: () => !!get(formState.errors, name),\n        },\n        isDirty: {\n          enumerable: true,\n          get: () => !!get(formState.dirtyFields, name),\n        },\n        isTouched: {\n          enumerable: true,\n          get: () => !!get(formState.touchedFields, name),\n        },\n        error: {\n          enumerable: true,\n          get: () => get(formState.errors, name),\n        },\n      },\n    ) as ControllerFieldState,\n  };\n}\n","import { ControllerProps, FieldPath, FieldValues } from './types';\nimport { useController } from './useController';\n\n/**\n * Component based on `useController` hook to work with controlled component.\n *\n * @remarks\n * [API](https://react-hook-form.com/api/usecontroller/controller) • [Demo](https://codesandbox.io/s/react-hook-form-v6-controller-ts-jwyzw) • [Video](https://www.youtube.com/watch?v=N2UNk_UCVyA)\n *\n * @param props - the path name to the form field value, and validation rules.\n *\n * @returns provide field handler functions, field and form state.\n *\n * @example\n * ```tsx\n * function App() {\n *   const { control } = useForm<FormValues>({\n *     defaultValues: {\n *       test: \"\"\n *     }\n *   });\n *\n *   return (\n *     <form>\n *       <Controller\n *         control={control}\n *         name=\"test\"\n *         render={({ field: { onChange, onBlur, value, ref }, formState, fieldState }) => (\n *           <>\n *             <input\n *               onChange={onChange} // send value to hook form\n *               onBlur={onBlur} // notify when input is touched\n *               value={value} // return updated value\n *               ref={ref} // set ref for focus management\n *             />\n *             <p>{formState.isSubmitted ? \"submitted\" : \"\"}</p>\n *             <p>{fieldState.isTouched ? \"touched\" : \"\"}</p>\n *           </>\n *         )}\n *       />\n *     </form>\n *   );\n * }\n * ```\n */\nconst Controller = <\n  TFieldValues extends FieldValues = FieldValues,\n  TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>(\n  props: ControllerProps<TFieldValues, TName>,\n) => props.render(useController<TFieldValues, TName>(props));\n\nexport { Controller };\n","import {\n  InternalFieldErrors,\n  InternalFieldName,\n  ValidateResult,\n} from '../types';\n\nexport default (\n  name: InternalFieldName,\n  validateAllFieldCriteria: boolean,\n  errors: InternalFieldErrors,\n  type: string,\n  message: ValidateResult,\n) =>\n  validateAllFieldCriteria\n    ? {\n        ...errors[name],\n        types: {\n          ...(errors[name] && errors[name]!.types ? errors[name]!.types : {}),\n          [type]: message || true,\n        },\n      }\n    : {};\n","export default (value: string) => /^\\w*$/.test(value);\n","import compact from './compact';\n\nexport default (input: string): string[] =>\n  compact(input.replace(/[\"|']|\\]/g, '').split(/\\.|\\[/));\n","import { FieldValues } from '../types';\n\nimport isKey from './isKey';\nimport isObject from './isObject';\nimport stringToPath from './stringToPath';\n\nexport default function set(\n  object: FieldValues,\n  path: string,\n  value?: unknown,\n) {\n  let index = -1;\n  const tempPath = isKey(path) ? [path] : stringToPath(path);\n  const length = tempPath.length;\n  const lastIndex = length - 1;\n\n  while (++index < length) {\n    const key = tempPath[index];\n    let newValue = value;\n\n    if (index !== lastIndex) {\n      const objValue = object[key];\n      newValue =\n        isObject(objValue) || Array.isArray(objValue)\n          ? objValue\n          : !isNaN(+tempPath[index + 1])\n          ? []\n          : {};\n    }\n    object[key] = newValue;\n    object = object[key];\n  }\n  return object;\n}\n","import { FieldRefs, InternalFieldName } from '../types';\nimport { get } from '../utils';\nimport isObject from '../utils/isObject';\n\nconst focusFieldBy = (\n  fields: FieldRefs,\n  callback: (name?: string) => boolean,\n  fieldsNames?: Set<InternalFieldName> | InternalFieldName[],\n) => {\n  for (const key of fieldsNames || Object.keys(fields)) {\n    const field = get(fields, key);\n\n    if (field) {\n      const { _f, ...currentField } = field;\n\n      if (_f && callback(_f.name)) {\n        if (_f.ref.focus) {\n          _f.ref.focus();\n          break;\n        } else if (_f.refs && _f.refs[0].focus) {\n          _f.refs[0].focus();\n          break;\n        }\n      } else if (isObject(currentField)) {\n        focusFieldBy(currentField, callback);\n      }\n    }\n  }\n};\n\nexport default focusFieldBy;\n","export default () => {\n  const d =\n    typeof performance === 'undefined' ? Date.now() : performance.now() * 1000;\n\n  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n    const r = (Math.random() * 16 + d) % 16 | 0;\n\n    return (c == 'x' ? r : (r & 0x3) | 0x8).toString(16);\n  });\n};\n","import { FieldArrayMethodProps, InternalFieldName } from '../types';\nimport isUndefined from '../utils/isUndefined';\n\nexport default (\n  name: InternalFieldName,\n  index: number,\n  options: FieldArrayMethodProps = {},\n): string =>\n  options.shouldFocus || isUndefined(options.shouldFocus)\n    ? options.focusName ||\n      `${name}.${isUndefined(options.focusIndex) ? index : options.focusIndex}.`\n    : '';\n","import { InternalFieldName, Names } from '../types';\n\nexport default (\n  name: InternalFieldName,\n  _names: Names,\n  isBlurEvent?: boolean,\n) =>\n  !isBlurEvent &&\n  (_names.watchAll ||\n    _names.watch.has(name) ||\n    [..._names.watch].some(\n      (watchName) =>\n        name.startsWith(watchName) &&\n        /^\\.\\w+/.test(name.slice(watchName.length)),\n    ));\n","import {\n  FieldError,\n  FieldErrors,\n  FieldValues,\n  InternalFieldName,\n} from '../types';\nimport compact from '../utils/compact';\nimport get from '../utils/get';\nimport set from '../utils/set';\n\nexport default <T extends FieldValues = FieldValues>(\n  errors: FieldErrors<T>,\n  error: Partial<Record<string, FieldError>>,\n  name: InternalFieldName,\n): FieldErrors<T> => {\n  const fieldArrayErrors = compact(get(errors, name));\n  set(fieldArrayErrors, 'root', error[name]);\n  set(errors, name, fieldArrayErrors);\n  return errors;\n};\n","export default (value: unknown): value is boolean => typeof value === 'boolean';\n","import { FieldElement } from '../types';\n\nexport default (element: FieldElement): element is HTMLInputElement =>\n  element.type === 'file';\n","import React from 'react';\n\nimport { Message } from '../types';\nimport isString from '../utils/isString';\n\nexport default (value: unknown): value is Message =>\n  isString(value) || React.isValidElement(value as JSX.Element);\n","import { FieldElement } from '../types';\n\nexport default (element: FieldElement): element is HTMLInputElement =>\n  element.type === 'radio';\n","export default (value: unknown): value is RegExp => value instanceof RegExp;\n","import isUndefined from '../utils/isUndefined';\n\ntype CheckboxFieldResult = {\n  isValid: boolean;\n  value: string | string[] | boolean | undefined;\n};\n\nconst defaultResult: CheckboxFieldResult = {\n  value: false,\n  isValid: false,\n};\n\nconst validResult = { value: true, isValid: true };\n\nexport default (options?: HTMLInputElement[]): CheckboxFieldResult => {\n  if (Array.isArray(options)) {\n    if (options.length > 1) {\n      const values = options\n        .filter((option) => option && option.checked && !option.disabled)\n        .map((option) => option.value);\n      return { value: values, isValid: !!values.length };\n    }\n\n    return options[0].checked && !options[0].disabled\n      ? // @ts-expect-error expected to work in the browser\n        options[0].attributes && !isUndefined(options[0].attributes.value)\n        ? isUndefined(options[0].value) || options[0].value === ''\n          ? validResult\n          : { value: options[0].value, isValid: true }\n        : validResult\n      : defaultResult;\n  }\n\n  return defaultResult;\n};\n","type RadioFieldResult = {\n  isValid: boolean;\n  value: number | string | null;\n};\n\nconst defaultReturn: RadioFieldResult = {\n  isValid: false,\n  value: null,\n};\n\nexport default (options?: HTMLInputElement[]): RadioFieldResult =>\n  Array.isArray(options)\n    ? options.reduce(\n        (previous, option): RadioFieldResult =>\n          option && option.checked && !option.disabled\n            ? {\n                isValid: true,\n                value: option.value,\n              }\n            : previous,\n        defaultReturn,\n      )\n    : defaultReturn;\n","import { FieldError, Ref, ValidateResult } from '../types';\nimport isBoolean from '../utils/isBoolean';\nimport isMessage from '../utils/isMessage';\n\nexport default function getValidateError(\n  result: ValidateResult,\n  ref: Ref,\n  type = 'validate',\n): FieldError | void {\n  if (\n    isMessage(result) ||\n    (Array.isArray(result) && result.every(isMessage)) ||\n    (isBoolean(result) && !result)\n  ) {\n    return {\n      type,\n      message: isMessage(result) ? result : '',\n      ref,\n    };\n  }\n}\n","import { ValidationRule } from '../types';\nimport isObject from '../utils/isObject';\nimport isRegex from '../utils/isRegex';\n\nexport default (validationData?: ValidationRule) =>\n  isObject(validationData) && !isRegex(validationData)\n    ? validationData\n    : {\n        value: validationData,\n        message: '',\n      };\n","import { INPUT_VALIDATION_RULES } from '../constants';\nimport {\n  Field,\n  FieldError,\n  InternalFieldErrors,\n  Message,\n  NativeFieldValue,\n} from '../types';\nimport isBoolean from '../utils/isBoolean';\nimport isCheckBoxInput from '../utils/isCheckBoxInput';\nimport isEmptyObject from '../utils/isEmptyObject';\nimport isFileInput from '../utils/isFileInput';\nimport isFunction from '../utils/isFunction';\nimport isMessage from '../utils/isMessage';\nimport isNullOrUndefined from '../utils/isNullOrUndefined';\nimport isObject from '../utils/isObject';\nimport isRadioInput from '../utils/isRadioInput';\nimport isRegex from '../utils/isRegex';\nimport isString from '../utils/isString';\n\nimport appendErrors from './appendErrors';\nimport getCheckboxValue from './getCheckboxValue';\nimport getRadioValue from './getRadioValue';\nimport getValidateError from './getValidateError';\nimport getValueAndMessage from './getValueAndMessage';\n\nexport default async <T extends NativeFieldValue>(\n  field: Field,\n  inputValue: T,\n  validateAllFieldCriteria: boolean,\n  shouldUseNativeValidation?: boolean,\n  isFieldArray?: boolean,\n): Promise<InternalFieldErrors> => {\n  const {\n    ref,\n    refs,\n    required,\n    maxLength,\n    minLength,\n    min,\n    max,\n    pattern,\n    validate,\n    name,\n    valueAsNumber,\n    mount,\n    disabled,\n  } = field._f;\n  if (!mount || disabled) {\n    return {};\n  }\n  const inputRef: HTMLInputElement = refs ? refs[0] : (ref as HTMLInputElement);\n  const setCustomValidity = (message?: string | boolean) => {\n    if (shouldUseNativeValidation && inputRef.reportValidity) {\n      inputRef.setCustomValidity(isBoolean(message) ? '' : message || ' ');\n      inputRef.reportValidity();\n    }\n  };\n  const error: InternalFieldErrors = {};\n  const isRadio = isRadioInput(ref);\n  const isCheckBox = isCheckBoxInput(ref);\n  const isRadioOrCheckbox = isRadio || isCheckBox;\n  const isEmpty =\n    ((valueAsNumber || isFileInput(ref)) && !ref.value) ||\n    inputValue === '' ||\n    (Array.isArray(inputValue) && !inputValue.length);\n  const appendErrorsCurry = appendErrors.bind(\n    null,\n    name,\n    validateAllFieldCriteria,\n    error,\n  );\n  const getMinMaxMessage = (\n    exceedMax: boolean,\n    maxLengthMessage: Message,\n    minLengthMessage: Message,\n    maxType = INPUT_VALIDATION_RULES.maxLength,\n    minType = INPUT_VALIDATION_RULES.minLength,\n  ) => {\n    const message = exceedMax ? maxLengthMessage : minLengthMessage;\n    error[name] = {\n      type: exceedMax ? maxType : minType,\n      message,\n      ref,\n      ...appendErrorsCurry(exceedMax ? maxType : minType, message),\n    };\n  };\n\n  if (\n    isFieldArray\n      ? !Array.isArray(inputValue) || !inputValue.length\n      : required &&\n        ((!isRadioOrCheckbox && (isEmpty || isNullOrUndefined(inputValue))) ||\n          (isBoolean(inputValue) && !inputValue) ||\n          (isCheckBox && !getCheckboxValue(refs).isValid) ||\n          (isRadio && !getRadioValue(refs).isValid))\n  ) {\n    const { value, message } = isMessage(required)\n      ? { value: !!required, message: required }\n      : getValueAndMessage(required);\n\n    if (value) {\n      error[name] = {\n        type: INPUT_VALIDATION_RULES.required,\n        message,\n        ref: inputRef,\n        ...appendErrorsCurry(INPUT_VALIDATION_RULES.required, message),\n      };\n      if (!validateAllFieldCriteria) {\n        setCustomValidity(message);\n        return error;\n      }\n    }\n  }\n\n  if (!isEmpty && (!isNullOrUndefined(min) || !isNullOrUndefined(max))) {\n    let exceedMax;\n    let exceedMin;\n    const maxOutput = getValueAndMessage(max);\n    const minOutput = getValueAndMessage(min);\n\n    if (!isNullOrUndefined(inputValue) && !isNaN(inputValue as number)) {\n      const valueNumber =\n        (ref as HTMLInputElement).valueAsNumber ||\n        (inputValue ? +inputValue : inputValue);\n      if (!isNullOrUndefined(maxOutput.value)) {\n        exceedMax = valueNumber > maxOutput.value;\n      }\n      if (!isNullOrUndefined(minOutput.value)) {\n        exceedMin = valueNumber < minOutput.value;\n      }\n    } else {\n      const valueDate =\n        (ref as HTMLInputElement).valueAsDate || new Date(inputValue as string);\n      const convertTimeToDate = (time: unknown) =>\n        new Date(new Date().toDateString() + ' ' + time);\n      const isTime = ref.type == 'time';\n      const isWeek = ref.type == 'week';\n\n      if (isString(maxOutput.value) && inputValue) {\n        exceedMax = isTime\n          ? convertTimeToDate(inputValue) > convertTimeToDate(maxOutput.value)\n          : isWeek\n          ? inputValue > maxOutput.value\n          : valueDate > new Date(maxOutput.value);\n      }\n\n      if (isString(minOutput.value) && inputValue) {\n        exceedMin = isTime\n          ? convertTimeToDate(inputValue) < convertTimeToDate(minOutput.value)\n          : isWeek\n          ? inputValue < minOutput.value\n          : valueDate < new Date(minOutput.value);\n      }\n    }\n\n    if (exceedMax || exceedMin) {\n      getMinMaxMessage(\n        !!exceedMax,\n        maxOutput.message,\n        minOutput.message,\n        INPUT_VALIDATION_RULES.max,\n        INPUT_VALIDATION_RULES.min,\n      );\n      if (!validateAllFieldCriteria) {\n        setCustomValidity(error[name]!.message);\n        return error;\n      }\n    }\n  }\n\n  if (\n    (maxLength || minLength) &&\n    !isEmpty &&\n    (isString(inputValue) || (isFieldArray && Array.isArray(inputValue)))\n  ) {\n    const maxLengthOutput = getValueAndMessage(maxLength);\n    const minLengthOutput = getValueAndMessage(minLength);\n    const exceedMax =\n      !isNullOrUndefined(maxLengthOutput.value) &&\n      inputValue.length > maxLengthOutput.value;\n    const exceedMin =\n      !isNullOrUndefined(minLengthOutput.value) &&\n      inputValue.length < minLengthOutput.value;\n\n    if (exceedMax || exceedMin) {\n      getMinMaxMessage(\n        exceedMax,\n        maxLengthOutput.message,\n        minLengthOutput.message,\n      );\n      if (!validateAllFieldCriteria) {\n        setCustomValidity(error[name]!.message);\n        return error;\n      }\n    }\n  }\n\n  if (pattern && !isEmpty && isString(inputValue)) {\n    const { value: patternValue, message } = getValueAndMessage(pattern);\n\n    if (isRegex(patternValue) && !inputValue.match(patternValue)) {\n      error[name] = {\n        type: INPUT_VALIDATION_RULES.pattern,\n        message,\n        ref,\n        ...appendErrorsCurry(INPUT_VALIDATION_RULES.pattern, message),\n      };\n      if (!validateAllFieldCriteria) {\n        setCustomValidity(message);\n        return error;\n      }\n    }\n  }\n\n  if (validate) {\n    if (isFunction(validate)) {\n      const result = await validate(inputValue);\n      const validateError = getValidateError(result, inputRef);\n\n      if (validateError) {\n        error[name] = {\n          ...validateError,\n          ...appendErrorsCurry(\n            INPUT_VALIDATION_RULES.validate,\n            validateError.message,\n          ),\n        };\n        if (!validateAllFieldCriteria) {\n          setCustomValidity(validateError.message);\n          return error;\n        }\n      }\n    } else if (isObject(validate)) {\n      let validationResult = {} as FieldError;\n\n      for (const key in validate) {\n        if (!isEmptyObject(validationResult) && !validateAllFieldCriteria) {\n          break;\n        }\n\n        const validateError = getValidateError(\n          await validate[key](inputValue),\n          inputRef,\n          key,\n        );\n\n        if (validateError) {\n          validationResult = {\n            ...validateError,\n            ...appendErrorsCurry(key, validateError.message),\n          };\n\n          setCustomValidity(validateError.message);\n\n          if (validateAllFieldCriteria) {\n            error[name] = validationResult;\n          }\n        }\n      }\n\n      if (!isEmptyObject(validationResult)) {\n        error[name] = {\n          ref: inputRef,\n          ...validationResult,\n        };\n        if (!validateAllFieldCriteria) {\n          return error;\n        }\n      }\n    }\n  }\n\n  setCustomValidity(true);\n  return error;\n};\n","import convertToArrayPayload from './convertToArrayPayload';\n\nexport default function append<T>(data: T[], value: T | T[]): T[] {\n  return [...data, ...convertToArrayPayload(value)];\n}\n","import isObject from './isObject';\n\nexport default (tempObject: object) => {\n  const prototypeCopy =\n    tempObject.constructor && tempObject.constructor.prototype;\n\n  return (\n    isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf')\n  );\n};\n","export default typeof window !== 'undefined' &&\n  typeof window.HTMLElement !== 'undefined' &&\n  typeof document !== 'undefined';\n","import isObject from './isObject';\nimport isPlainObject from './isPlainObject';\nimport isWeb from './isWeb';\n\nexport default function cloneObject<T>(data: T): T {\n  let copy: any;\n  const isArray = Array.isArray(data);\n\n  if (data instanceof Date) {\n    copy = new Date(data);\n  } else if (data instanceof Set) {\n    copy = new Set(data);\n  } else if (\n    !(isWeb && (data instanceof Blob || data instanceof FileList)) &&\n    (isArray || isObject(data))\n  ) {\n    copy = isArray ? [] : {};\n\n    if (!Array.isArray(data) && !isPlainObject(data)) {\n      copy = data;\n    } else {\n      for (const key in data) {\n        copy[key] = cloneObject(data[key]);\n      }\n    }\n  } else {\n    return data;\n  }\n\n  return copy;\n}\n","export default <T>(value: T | T[]): undefined[] | undefined =>\n  Array.isArray(value) ? value.map(() => undefined) : undefined;\n","import { VALIDATION_MODE } from '../constants';\nimport { Mode } from '../types';\n\nexport default (\n  mode?: Mode,\n): {\n  isOnSubmit: boolean;\n  isOnBlur: boolean;\n  isOnChange: boolean;\n  isOnAll: boolean;\n  isOnTouch: boolean;\n} => ({\n  isOnSubmit: !mode || mode === VALIDATION_MODE.onSubmit,\n  isOnBlur: mode === VALIDATION_MODE.onBlur,\n  isOnChange: mode === VALIDATION_MODE.onChange,\n  isOnAll: mode === VALIDATION_MODE.all,\n  isOnTouch: mode === VALIDATION_MODE.onTouched,\n});\n","import convertToArrayPayload from './convertToArrayPayload';\n\nexport default function insert<T>(data: T[], index: number): (T | undefined)[];\nexport default function insert<T>(\n  data: T[],\n  index: number,\n  value: T | T[],\n): T[];\nexport default function insert<T>(\n  data: T[],\n  index: number,\n  value?: T | T[],\n): (T | undefined)[] {\n  return [\n    ...data.slice(0, index),\n    ...convertToArrayPayload(value),\n    ...data.slice(index),\n  ];\n}\n","import isUndefined from './isUndefined';\n\nexport default <T>(\n  data: (T | undefined)[],\n  from: number,\n  to: number,\n): (T | undefined)[] => {\n  if (!Array.isArray(data)) {\n    return [];\n  }\n\n  if (isUndefined(data[to])) {\n    data[to] = undefined;\n  }\n  data.splice(to, 0, data.splice(from, 1)[0]);\n\n  return data;\n};\n","import convertToArrayPayload from './convertToArrayPayload';\n\nexport default function prepend<T>(data: T[], value: T | T[]): T[] {\n  return [...convertToArrayPayload(value), ...convertToArrayPayload(data)];\n}\n","import compact from './compact';\nimport convertToArrayPayload from './convertToArrayPayload';\nimport isUndefined from './isUndefined';\n\nfunction removeAtIndexes<T>(data: T[], indexes: number[]): T[] {\n  let i = 0;\n  const temp = [...data];\n\n  for (const index of indexes) {\n    temp.splice(index - i, 1);\n    i++;\n  }\n\n  return compact(temp).length ? temp : [];\n}\n\nexport default <T>(data: T[], index?: number | number[]): T[] =>\n  isUndefined(index)\n    ? []\n    : removeAtIndexes(\n        data,\n        (convertToArrayPayload(index) as number[]).sort((a, b) => a - b),\n      );\n","export default <T>(data: T[], indexA: number, indexB: number): void => {\n  data[indexA] = [data[indexB], (data[indexB] = data[indexA])][0];\n};\n","import isEmptyObject from './isEmptyObject';\nimport isKey from './isKey';\nimport isObject from './isObject';\nimport isUndefined from './isUndefined';\nimport stringToPath from './stringToPath';\n\nfunction baseGet(object: any, updatePath: (string | number)[]) {\n  const length = updatePath.slice(0, -1).length;\n  let index = 0;\n\n  while (index < length) {\n    object = isUndefined(object) ? index++ : object[updatePath[index++]];\n  }\n\n  return object;\n}\n\nfunction isEmptyArray(obj: unknown[]) {\n  for (const key in obj) {\n    if (!isUndefined(obj[key])) {\n      return false;\n    }\n  }\n  return true;\n}\n\nexport default function unset(object: any, path: string) {\n  const updatePath = isKey(path) ? [path] : stringToPath(path);\n  const childObject =\n    updatePath.length == 1 ? object : baseGet(object, updatePath);\n  const key = updatePath[updatePath.length - 1];\n  let previousObjRef;\n\n  if (childObject) {\n    delete childObject[key];\n  }\n\n  for (let k = 0; k < updatePath.slice(0, -1).length; k++) {\n    let index = -1;\n    let objectRef;\n    const currentPaths = updatePath.slice(0, -(k + 1));\n    const currentPathsLength = currentPaths.length - 1;\n\n    if (k > 0) {\n      previousObjRef = object;\n    }\n\n    while (++index < currentPaths.length) {\n      const item = currentPaths[index];\n      objectRef = objectRef ? objectRef[item] : object[item];\n\n      if (\n        currentPathsLength === index &&\n        ((isObject(objectRef) && isEmptyObject(objectRef)) ||\n          (Array.isArray(objectRef) && isEmptyArray(objectRef)))\n      ) {\n        previousObjRef ? delete previousObjRef[item] : delete object[item];\n      }\n\n      previousObjRef = objectRef;\n    }\n  }\n\n  return object;\n}\n","export default <T>(fieldValues: T[], index: number, value: T) => {\n  fieldValues[index] = value;\n  return fieldValues;\n};\n","import React from 'react';\n\nimport focusFieldBy from './logic/focusFieldBy';\nimport generateId from './logic/generateId';\nimport getFocusFieldName from './logic/getFocusFieldName';\nimport isWatched from './logic/isWatched';\nimport updateFieldArrayRootError from './logic/updateFieldArrayRootError';\nimport validateField from './logic/validateField';\nimport appendAt from './utils/append';\nimport cloneObject from './utils/cloneObject';\nimport convertToArrayPayload from './utils/convertToArrayPayload';\nimport fillEmptyArray from './utils/fillEmptyArray';\nimport get from './utils/get';\nimport getValidationModes from './utils/getValidationModes';\nimport insertAt from './utils/insert';\nimport isEmptyObject from './utils/isEmptyObject';\nimport moveArrayAt from './utils/move';\nimport prependAt from './utils/prepend';\nimport removeArrayAt from './utils/remove';\nimport set from './utils/set';\nimport swapArrayAt from './utils/swap';\nimport unset from './utils/unset';\nimport updateAt from './utils/update';\nimport { VALIDATION_MODE } from './constants';\nimport {\n  Control,\n  Field,\n  FieldArray,\n  FieldArrayMethodProps,\n  FieldArrayPath,\n  FieldArrayWithId,\n  FieldErrors,\n  FieldPath,\n  FieldValues,\n  InternalFieldName,\n  RegisterOptions,\n  UseFieldArrayProps,\n  UseFieldArrayReturn,\n} from './types';\nimport { useFormContext } from './useFormContext';\nimport { useSubscribe } from './useSubscribe';\n\n/**\n * A custom hook that exposes convenient methods to perform operations with a list of dynamic inputs that need to be appended, updated, removed etc. • [Demo](https://codesandbox.io/s/react-hook-form-usefieldarray-ssugn) • [Video](https://youtu.be/4MrbfGSFY2A)\n *\n * @remarks\n * [API](https://react-hook-form.com/api/usefieldarray) • [Demo](https://codesandbox.io/s/react-hook-form-usefieldarray-ssugn)\n *\n * @param props - useFieldArray props\n *\n * @returns methods - functions to manipulate with the Field Arrays (dynamic inputs) {@link UseFieldArrayReturn}\n *\n * @example\n * ```tsx\n * function App() {\n *   const { register, control, handleSubmit, reset, trigger, setError } = useForm({\n *     defaultValues: {\n *       test: []\n *     }\n *   });\n *   const { fields, append } = useFieldArray({\n *     control,\n *     name: \"test\"\n *   });\n *\n *   return (\n *     <form onSubmit={handleSubmit(data => console.log(data))}>\n *       {fields.map((item, index) => (\n *          <input key={item.id} {...register(`test.${index}.firstName`)}  />\n *       ))}\n *       <button type=\"button\" onClick={() => append({ firstName: \"bill\" })}>\n *         append\n *       </button>\n *       <input type=\"submit\" />\n *     </form>\n *   );\n * }\n * ```\n */\nexport function useFieldArray<\n  TFieldValues extends FieldValues = FieldValues,\n  TFieldArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>,\n  TKeyName extends string = 'id',\n>(\n  props: UseFieldArrayProps<TFieldValues, TFieldArrayName, TKeyName>,\n): UseFieldArrayReturn<TFieldValues, TFieldArrayName, TKeyName> {\n  const methods = useFormContext();\n  const {\n    control = methods.control,\n    name,\n    keyName = 'id',\n    shouldUnregister,\n  } = props;\n  const [fields, setFields] = React.useState(control._getFieldArray(name));\n  const ids = React.useRef<string[]>(\n    control._getFieldArray(name).map(generateId),\n  );\n  const _fieldIds = React.useRef(fields);\n  const _name = React.useRef(name);\n  const _actioned = React.useRef(false);\n\n  _name.current = name;\n  _fieldIds.current = fields;\n  control._names.array.add(name);\n\n  props.rules &&\n    (control as Control).register(\n      name as FieldPath<TFieldValues>,\n      props.rules as RegisterOptions<TFieldValues>,\n    );\n\n  const callback = React.useCallback(\n    ({\n      values,\n      name: fieldArrayName,\n    }: {\n      values?: FieldValues;\n      name?: InternalFieldName;\n    }) => {\n      if (fieldArrayName === _name.current || !fieldArrayName) {\n        const fieldValues = get(values, _name.current);\n        if (Array.isArray(fieldValues)) {\n          setFields(fieldValues);\n          ids.current = fieldValues.map(generateId);\n        }\n      }\n    },\n    [],\n  );\n\n  useSubscribe({\n    callback,\n    subject: control._subjects.array,\n  });\n\n  const updateValues = React.useCallback(\n    <\n      T extends Partial<\n        FieldArrayWithId<TFieldValues, TFieldArrayName, TKeyName>\n      >[],\n    >(\n      updatedFieldArrayValues: T,\n    ) => {\n      _actioned.current = true;\n      control._updateFieldArray(name, updatedFieldArrayValues);\n    },\n    [control, name],\n  );\n\n  const append = (\n    value:\n      | Partial<FieldArray<TFieldValues, TFieldArrayName>>\n      | Partial<FieldArray<TFieldValues, TFieldArrayName>>[],\n    options?: FieldArrayMethodProps,\n  ) => {\n    const appendValue = convertToArrayPayload(cloneObject(value));\n    const updatedFieldArrayValues = appendAt(\n      control._getFieldArray(name),\n      appendValue,\n    );\n    control._names.focus = getFocusFieldName(\n      name,\n      updatedFieldArrayValues.length - 1,\n      options,\n    );\n    ids.current = appendAt(ids.current, appendValue.map(generateId));\n    updateValues(updatedFieldArrayValues);\n    setFields(updatedFieldArrayValues);\n    control._updateFieldArray(name, updatedFieldArrayValues, appendAt, {\n      argA: fillEmptyArray(value),\n    });\n  };\n\n  const prepend = (\n    value:\n      | Partial<FieldArray<TFieldValues, TFieldArrayName>>\n      | Partial<FieldArray<TFieldValues, TFieldArrayName>>[],\n    options?: FieldArrayMethodProps,\n  ) => {\n    const prependValue = convertToArrayPayload(cloneObject(value));\n    const updatedFieldArrayValues = prependAt(\n      control._getFieldArray(name),\n      prependValue,\n    );\n    control._names.focus = getFocusFieldName(name, 0, options);\n    ids.current = prependAt(ids.current, prependValue.map(generateId));\n    updateValues(updatedFieldArrayValues);\n    setFields(updatedFieldArrayValues);\n    control._updateFieldArray(name, updatedFieldArrayValues, prependAt, {\n      argA: fillEmptyArray(value),\n    });\n  };\n\n  const remove = (index?: number | number[]) => {\n    const updatedFieldArrayValues: Partial<\n      FieldArrayWithId<TFieldValues, TFieldArrayName, TKeyName>\n    >[] = removeArrayAt(control._getFieldArray(name), index);\n    ids.current = removeArrayAt(ids.current, index);\n    updateValues(updatedFieldArrayValues);\n    setFields(updatedFieldArrayValues);\n    control._updateFieldArray(name, updatedFieldArrayValues, removeArrayAt, {\n      argA: index,\n    });\n  };\n\n  const insert = (\n    index: number,\n    value:\n      | Partial<FieldArray<TFieldValues, TFieldArrayName>>\n      | Partial<FieldArray<TFieldValues, TFieldArrayName>>[],\n    options?: FieldArrayMethodProps,\n  ) => {\n    const insertValue = convertToArrayPayload(cloneObject(value));\n    const updatedFieldArrayValues = insertAt(\n      control._getFieldArray(name),\n      index,\n      insertValue,\n    );\n    control._names.focus = getFocusFieldName(name, index, options);\n    ids.current = insertAt(ids.current, index, insertValue.map(generateId));\n    updateValues(updatedFieldArrayValues);\n    setFields(updatedFieldArrayValues);\n    control._updateFieldArray(name, updatedFieldArrayValues, insertAt, {\n      argA: index,\n      argB: fillEmptyArray(value),\n    });\n  };\n\n  const swap = (indexA: number, indexB: number) => {\n    const updatedFieldArrayValues = control._getFieldArray(name);\n    swapArrayAt(updatedFieldArrayValues, indexA, indexB);\n    swapArrayAt(ids.current, indexA, indexB);\n    updateValues(updatedFieldArrayValues);\n    setFields(updatedFieldArrayValues);\n    control._updateFieldArray(\n      name,\n      updatedFieldArrayValues,\n      swapArrayAt,\n      {\n        argA: indexA,\n        argB: indexB,\n      },\n      false,\n    );\n  };\n\n  const move = (from: number, to: number) => {\n    const updatedFieldArrayValues = control._getFieldArray(name);\n    moveArrayAt(updatedFieldArrayValues, from, to);\n    moveArrayAt(ids.current, from, to);\n    updateValues(updatedFieldArrayValues);\n    setFields(updatedFieldArrayValues);\n    control._updateFieldArray(\n      name,\n      updatedFieldArrayValues,\n      moveArrayAt,\n      {\n        argA: from,\n        argB: to,\n      },\n      false,\n    );\n  };\n\n  const update = (\n    index: number,\n    value: FieldArray<TFieldValues, TFieldArrayName>,\n  ) => {\n    const updateValue = cloneObject(value);\n    const updatedFieldArrayValues = updateAt(\n      control._getFieldArray<\n        FieldArrayWithId<TFieldValues, TFieldArrayName, TKeyName>\n      >(name),\n      index,\n      updateValue as FieldArrayWithId<TFieldValues, TFieldArrayName, TKeyName>,\n    );\n    ids.current = [...updatedFieldArrayValues].map((item, i) =>\n      !item || i === index ? generateId() : ids.current[i],\n    );\n    updateValues(updatedFieldArrayValues);\n    setFields([...updatedFieldArrayValues]);\n    control._updateFieldArray(\n      name,\n      updatedFieldArrayValues,\n      updateAt,\n      {\n        argA: index,\n        argB: updateValue,\n      },\n      true,\n      false,\n    );\n  };\n\n  const replace = (\n    value:\n      | Partial<FieldArray<TFieldValues, TFieldArrayName>>\n      | Partial<FieldArray<TFieldValues, TFieldArrayName>>[],\n  ) => {\n    const updatedFieldArrayValues = convertToArrayPayload(cloneObject(value));\n    ids.current = updatedFieldArrayValues.map(generateId);\n    updateValues([...updatedFieldArrayValues]);\n    setFields([...updatedFieldArrayValues]);\n    control._updateFieldArray(\n      name,\n      [...updatedFieldArrayValues],\n      <T>(data: T): T => data,\n      {},\n      true,\n      false,\n    );\n  };\n\n  React.useEffect(() => {\n    control._stateFlags.action = false;\n\n    isWatched(name, control._names) && control._subjects.state.next({});\n\n    if (\n      _actioned.current &&\n      (!getValidationModes(control._options.mode).isOnSubmit ||\n        control._formState.isSubmitted)\n    ) {\n      if (control._options.resolver) {\n        control._executeSchema([name]).then((result) => {\n          const error = get(result.errors, name);\n          const existingError = get(control._formState.errors, name);\n\n          if (\n            existingError ? !error && existingError.type : error && error.type\n          ) {\n            error\n              ? set(control._formState.errors, name, error)\n              : unset(control._formState.errors, name);\n            control._subjects.state.next({\n              errors: control._formState.errors as FieldErrors<TFieldValues>,\n            });\n          }\n        });\n      } else {\n        const field: Field = get(control._fields, name);\n        if (field && field._f) {\n          validateField(\n            field,\n            get(control._formValues, name),\n            control._options.criteriaMode === VALIDATION_MODE.all,\n            control._options.shouldUseNativeValidation,\n            true,\n          ).then(\n            (error) =>\n              !isEmptyObject(error) &&\n              control._subjects.state.next({\n                errors: updateFieldArrayRootError(\n                  control._formState.errors,\n                  error,\n                  name,\n                ) as FieldErrors<TFieldValues>,\n              }),\n          );\n        }\n      }\n    }\n\n    control._subjects.watch.next({\n      name,\n      values: control._formValues,\n    });\n\n    control._names.focus &&\n      focusFieldBy(\n        control._fields,\n        (key) => !!key && key.startsWith(control._names.focus),\n      );\n\n    control._names.focus = '';\n\n    control._proxyFormState.isValid && control._updateValid();\n  }, [fields, name, control]);\n\n  React.useEffect(() => {\n    !get(control._formValues, name) && control._updateFieldArray(name);\n\n    return () => {\n      (control._options.shouldUnregister || shouldUnregister) &&\n        control.unregister(name as FieldPath<TFieldValues>);\n    };\n  }, [name, control, keyName, shouldUnregister]);\n\n  return {\n    swap: React.useCallback(swap, [updateValues, name, control]),\n    move: React.useCallback(move, [updateValues, name, control]),\n    prepend: React.useCallback(prepend, [updateValues, name, control]),\n    append: React.useCallback(append, [updateValues, name, control]),\n    remove: React.useCallback(remove, [updateValues, name, control]),\n    insert: React.useCallback(insert, [updateValues, name, control]),\n    update: React.useCallback(update, [updateValues, name, control]),\n    replace: React.useCallback(replace, [updateValues, name, control]),\n    fields: React.useMemo(\n      () =>\n        fields.map((field, index) => ({\n          ...field,\n          [keyName]: ids.current[index] || generateId(),\n        })) as FieldArrayWithId<TFieldValues, TFieldArrayName, TKeyName>[],\n      [fields, keyName],\n    ),\n  };\n}\n","import { Noop } from '../types';\n\nexport type Observer<T> = {\n  next: (value: T) => void;\n};\n\nexport type Subscription = {\n  unsubscribe: Noop;\n};\n\nexport type Subject<T> = {\n  readonly observers: Observer<T>[];\n  subscribe: (value: Observer<T>) => Subscription;\n  unsubscribe: Noop;\n} & Observer<T>;\n\nexport default function createSubject<T>(): Subject<T> {\n  let _observers: Observer<T>[] = [];\n\n  const next = (value: T) => {\n    for (const observer of _observers) {\n      observer.next(value);\n    }\n  };\n\n  const subscribe = (observer: Observer<T>): Subscription => {\n    _observers.push(observer);\n    return {\n      unsubscribe: () => {\n        _observers = _observers.filter((o) => o !== observer);\n      },\n    };\n  };\n\n  const unsubscribe = () => {\n    _observers = [];\n  };\n\n  return {\n    get observers() {\n      return _observers;\n    },\n    next,\n    subscribe,\n    unsubscribe,\n  };\n}\n","import { Primitive } from '../types';\n\nimport isNullOrUndefined from './isNullOrUndefined';\nimport { isObjectType } from './isObject';\n\nexport default (value: unknown): value is Primitive =>\n  isNullOrUndefined(value) || !isObjectType(value);\n","import isObject from '../utils/isObject';\n\nimport isDateObject from './isDateObject';\nimport isPrimitive from './isPrimitive';\n\nexport default function deepEqual(object1: any, object2: any) {\n  if (isPrimitive(object1) || isPrimitive(object2)) {\n    return object1 === object2;\n  }\n\n  if (isDateObject(object1) && isDateObject(object2)) {\n    return object1.getTime() === object2.getTime();\n  }\n\n  const keys1 = Object.keys(object1);\n  const keys2 = Object.keys(object2);\n\n  if (keys1.length !== keys2.length) {\n    return false;\n  }\n\n  for (const key of keys1) {\n    const val1 = object1[key];\n\n    if (!keys2.includes(key)) {\n      return false;\n    }\n\n    if (key !== 'ref') {\n      const val2 = object2[key];\n\n      if (\n        (isDateObject(val1) && isDateObject(val2)) ||\n        (isObject(val1) && isObject(val2)) ||\n        (Array.isArray(val1) && Array.isArray(val2))\n          ? !deepEqual(val1, val2)\n          : val1 !== val2\n      ) {\n        return false;\n      }\n    }\n  }\n\n  return true;\n}\n","export default (value: unknown): value is HTMLElement => {\n  const owner = value ? ((value as HTMLElement).ownerDocument as Document) : 0;\n  const ElementClass =\n    owner && owner.defaultView ? owner.defaultView.HTMLElement : HTMLElement;\n  return value instanceof ElementClass;\n};\n","import { FieldElement } from '../types';\n\nexport default (element: FieldElement): element is HTMLSelectElement =>\n  element.type === `select-multiple`;\n","import { FieldElement } from '../types';\n\nimport isCheckBoxInput from './isCheckBoxInput';\nimport isRadioInput from './isRadioInput';\n\nexport default (ref: FieldElement): ref is HTMLInputElement =>\n  isRadioInput(ref) || isCheckBoxInput(ref);\n","import { Ref } from '../types';\n\nimport isHTMLElement from './isHTMLElement';\n\nexport default (ref: Ref) => isHTMLElement(ref) && ref.isConnected;\n","import deepEqual from '../utils/deepEqual';\nimport isNullOrUndefined from '../utils/isNullOrUndefined';\nimport isObject from '../utils/isObject';\nimport isPrimitive from '../utils/isPrimitive';\nimport isUndefined from '../utils/isUndefined';\nimport objectHasFunction from '../utils/objectHasFunction';\n\nfunction markFieldsDirty<U>(data: U, fields: Record<string, any> = {}) {\n  const isParentNodeArray = Array.isArray(data);\n\n  if (isObject(data) || isParentNodeArray) {\n    for (const key in data) {\n      if (\n        Array.isArray(data[key]) ||\n        (isObject(data[key]) && !objectHasFunction(data[key]))\n      ) {\n        fields[key] = Array.isArray(data[key]) ? [] : {};\n        markFieldsDirty(data[key], fields[key]);\n      } else if (!isNullOrUndefined(data[key])) {\n        fields[key] = true;\n      }\n    }\n  }\n\n  return fields;\n}\n\nfunction getDirtyFieldsFromDefaultValues<T>(\n  data: T,\n  formValues: T,\n  dirtyFieldsFromValues: any,\n) {\n  const isParentNodeArray = Array.isArray(data);\n\n  if (isObject(data) || isParentNodeArray) {\n    for (const key in data) {\n      if (\n        Array.isArray(data[key]) ||\n        (isObject(data[key]) && !objectHasFunction(data[key]))\n      ) {\n        if (\n          isUndefined(formValues) ||\n          isPrimitive(dirtyFieldsFromValues[key])\n        ) {\n          dirtyFieldsFromValues[key] = Array.isArray(data[key])\n            ? markFieldsDirty(data[key], [])\n            : { ...markFieldsDirty(data[key]) };\n        } else {\n          getDirtyFieldsFromDefaultValues(\n            data[key],\n            isNullOrUndefined(formValues) ? {} : formValues[key],\n            dirtyFieldsFromValues[key],\n          );\n        }\n      } else {\n        dirtyFieldsFromValues[key] = !deepEqual(data[key], formValues[key]);\n      }\n    }\n  }\n\n  return dirtyFieldsFromValues;\n}\n\nexport default <T>(defaultValues: T, formValues: T) =>\n  getDirtyFieldsFromDefaultValues(\n    defaultValues,\n    formValues,\n    markFieldsDirty(formValues),\n  );\n","import { Field, NativeFieldValue } from '../types';\nimport isString from '../utils/isString';\nimport isUndefined from '../utils/isUndefined';\n\nexport default <T extends NativeFieldValue>(\n  value: T,\n  { valueAsNumber, valueAsDate, setValueAs }: Field['_f'],\n) =>\n  isUndefined(value)\n    ? value\n    : valueAsNumber\n    ? value === ''\n      ? NaN\n      : value\n      ? +value\n      : value\n    : valueAsDate && isString(value)\n    ? new Date(value)\n    : setValueAs\n    ? setValueAs(value)\n    : value;\n","import { Field } from '../types';\nimport isCheckBox from '../utils/isCheckBoxInput';\nimport isFileInput from '../utils/isFileInput';\nimport isMultipleSelect from '../utils/isMultipleSelect';\nimport isRadioInput from '../utils/isRadioInput';\nimport isUndefined from '../utils/isUndefined';\n\nimport getCheckboxValue from './getCheckboxValue';\nimport getFieldValueAs from './getFieldValueAs';\nimport getRadioValue from './getRadioValue';\n\nexport default function getFieldValue(_f: Field['_f']) {\n  const ref = _f.ref;\n\n  if (_f.refs ? _f.refs.every((ref) => ref.disabled) : ref.disabled) {\n    return;\n  }\n\n  if (isFileInput(ref)) {\n    return ref.files;\n  }\n\n  if (isRadioInput(ref)) {\n    return getRadioValue(_f.refs).value;\n  }\n\n  if (isMultipleSelect(ref)) {\n    return [...ref.selectedOptions].map(({ value }) => value);\n  }\n\n  if (isCheckBox(ref)) {\n    return getCheckboxValue(_f.refs).value;\n  }\n\n  return getFieldValueAs(isUndefined(ref.value) ? _f.ref.value : ref.value, _f);\n}\n","import {\n  CriteriaMode,\n  Field,\n  FieldName,\n  FieldRefs,\n  FieldValues,\n  InternalFieldName,\n} from '../types';\nimport { get } from '../utils';\nimport set from '../utils/set';\n\nexport default <TFieldValues extends FieldValues>(\n  fieldsNames: Set<InternalFieldName> | InternalFieldName[],\n  _fields: FieldRefs,\n  criteriaMode?: CriteriaMode,\n  shouldUseNativeValidation?: boolean | undefined,\n) => {\n  const fields: Record<InternalFieldName, Field['_f']> = {};\n\n  for (const name of fieldsNames) {\n    const field: Field = get(_fields, name);\n\n    field && set(fields, name, field._f);\n  }\n\n  return {\n    criteriaMode,\n    names: [...fieldsNames] as FieldName<TFieldValues>[],\n    fields,\n    shouldUseNativeValidation,\n  };\n};\n","import {\n  ValidationRule,\n  ValidationValue,\n  ValidationValueMessage,\n} from '../types';\nimport isObject from '../utils/isObject';\nimport isRegex from '../utils/isRegex';\nimport isUndefined from '../utils/isUndefined';\n\nexport default <T extends ValidationValue>(\n  rule?: ValidationRule<T> | ValidationValueMessage<T>,\n) =>\n  isUndefined(rule)\n    ? undefined\n    : isRegex(rule)\n    ? rule.source\n    : isObject(rule)\n    ? isRegex(rule.value)\n      ? rule.value.source\n      : rule.value\n    : rule;\n","import { Field } from '../types';\n\nexport default (options: Field['_f']) =>\n  options.mount &&\n  (options.required ||\n    options.min ||\n    options.max ||\n    options.maxLength ||\n    options.minLength ||\n    options.pattern ||\n    options.validate);\n","import { FieldError, FieldErrors, FieldValues } from '../types';\nimport get from '../utils/get';\nimport isKey from '../utils/isKey';\n\nexport default function schemaErrorLookup<T extends FieldValues = FieldValues>(\n  errors: FieldErrors<T>,\n  _fields: FieldValues,\n  name: string,\n): {\n  error?: FieldError;\n  name: string;\n} {\n  const error = get(errors, name);\n\n  if (error || isKey(name)) {\n    return {\n      error,\n      name,\n    };\n  }\n\n  const names = name.split('.');\n\n  while (names.length) {\n    const fieldName = names.join('.');\n    const field = get(_fields, fieldName);\n    const foundError = get(errors, fieldName);\n\n    if (field && !Array.isArray(field) && name !== fieldName) {\n      return { name };\n    }\n\n    if (foundError && foundError.type) {\n      return {\n        name: fieldName,\n        error: foundError,\n      };\n    }\n\n    names.pop();\n  }\n\n  return {\n    name,\n  };\n}\n","export default (\n  isBlurEvent: boolean,\n  isTouched: boolean,\n  isSubmitted: boolean,\n  reValidateMode: {\n    isOnBlur: boolean;\n    isOnChange: boolean;\n  },\n  mode: Partial<{\n    isOnSubmit: boolean;\n    isOnBlur: boolean;\n    isOnChange: boolean;\n    isOnTouch: boolean;\n    isOnAll: boolean;\n  }>,\n) => {\n  if (mode.isOnAll) {\n    return false;\n  } else if (!isSubmitted && mode.isOnTouch) {\n    return !(isTouched || isBlurEvent);\n  } else if (isSubmitted ? reValidateMode.isOnBlur : mode.isOnBlur) {\n    return !isBlurEvent;\n  } else if (isSubmitted ? reValidateMode.isOnChange : mode.isOnChange) {\n    return isBlurEvent;\n  }\n  return true;\n};\n","import compact from '../utils/compact';\nimport get from '../utils/get';\nimport unset from '../utils/unset';\n\nexport default <T>(ref: T, name: string) =>\n  !compact(get(ref, name)).length && unset(ref, name);\n","import { EVENTS, VALIDATION_MODE } from '../constants';\nimport {\n  BatchFieldArrayUpdate,\n  ChangeHandler,\n  DeepPartial,\n  DelayCallback,\n  EventType,\n  Field,\n  FieldError,\n  FieldNamesMarkedBoolean,\n  FieldPath,\n  FieldRefs,\n  FieldValues,\n  FormState,\n  GetIsDirty,\n  InternalFieldName,\n  Names,\n  Path,\n  Ref,\n  ResolverResult,\n  SetFieldValue,\n  SetValueConfig,\n  Subjects,\n  UseFormClearErrors,\n  UseFormGetFieldState,\n  UseFormGetValues,\n  UseFormHandleSubmit,\n  UseFormProps,\n  UseFormRegister,\n  UseFormReset,\n  UseFormResetField,\n  UseFormReturn,\n  UseFormSetError,\n  UseFormSetFocus,\n  UseFormSetValue,\n  UseFormTrigger,\n  UseFormUnregister,\n  UseFormWatch,\n  WatchInternal,\n  WatchObserver,\n} from '../types';\nimport cloneObject from '../utils/cloneObject';\nimport compact from '../utils/compact';\nimport convertToArrayPayload from '../utils/convertToArrayPayload';\nimport createSubject from '../utils/createSubject';\nimport deepEqual from '../utils/deepEqual';\nimport get from '../utils/get';\nimport getValidationModes from '../utils/getValidationModes';\nimport isBoolean from '../utils/isBoolean';\nimport isCheckBoxInput from '../utils/isCheckBoxInput';\nimport isDateObject from '../utils/isDateObject';\nimport isEmptyObject from '../utils/isEmptyObject';\nimport isFileInput from '../utils/isFileInput';\nimport isFunction from '../utils/isFunction';\nimport isHTMLElement from '../utils/isHTMLElement';\nimport isMultipleSelect from '../utils/isMultipleSelect';\nimport isNullOrUndefined from '../utils/isNullOrUndefined';\nimport isPrimitive from '../utils/isPrimitive';\nimport isRadioOrCheckbox from '../utils/isRadioOrCheckbox';\nimport isString from '../utils/isString';\nimport isUndefined from '../utils/isUndefined';\nimport isWeb from '../utils/isWeb';\nimport live from '../utils/live';\nimport set from '../utils/set';\nimport unset from '../utils/unset';\n\nimport focusFieldBy from './focusFieldBy';\nimport generateWatchOutput from './generateWatchOutput';\nimport getDirtyFields from './getDirtyFields';\nimport getEventValue from './getEventValue';\nimport getFieldValue from './getFieldValue';\nimport getFieldValueAs from './getFieldValueAs';\nimport getResolverOptions from './getResolverOptions';\nimport getRuleValue from './getRuleValue';\nimport hasValidation from './hasValidation';\nimport isNameInFieldArray from './isNameInFieldArray';\nimport isWatched from './isWatched';\nimport schemaErrorLookup from './schemaErrorLookup';\nimport skipValidation from './skipValidation';\nimport unsetEmptyArray from './unsetEmptyArray';\nimport updateFieldArrayRootError from './updateFieldArrayRootError';\nimport validateField from './validateField';\n\nconst defaultOptions = {\n  mode: VALIDATION_MODE.onSubmit,\n  reValidateMode: VALIDATION_MODE.onChange,\n  shouldFocusError: true,\n} as const;\n\nexport function createFormControl<\n  TFieldValues extends FieldValues = FieldValues,\n  TContext = any,\n>(\n  props: UseFormProps<TFieldValues, TContext> = {},\n): Omit<UseFormReturn<TFieldValues, TContext>, 'formState'> {\n  let _options = {\n    ...defaultOptions,\n    ...props,\n  };\n  let _formState: FormState<TFieldValues> = {\n    submitCount: 0,\n    isDirty: false,\n    isValidating: false,\n    isSubmitted: false,\n    isSubmitting: false,\n    isSubmitSuccessful: false,\n    isValid: false,\n    touchedFields: {},\n    dirtyFields: {},\n    errors: {},\n  };\n  let _fields = {};\n  let _defaultValues = cloneObject(_options.defaultValues) || {};\n  let _formValues = _options.shouldUnregister\n    ? {}\n    : cloneObject(_defaultValues);\n  let _stateFlags = {\n    action: false,\n    mount: false,\n    watch: false,\n  };\n  let _names: Names = {\n    mount: new Set(),\n    unMount: new Set(),\n    array: new Set(),\n    watch: new Set(),\n  } as Names;\n  let delayErrorCallback: DelayCallback | null;\n  let timer = 0;\n  let validateFields: Record<InternalFieldName, number> = {};\n  const _proxyFormState = {\n    isDirty: false,\n    dirtyFields: false,\n    touchedFields: false,\n    isValidating: false,\n    isValid: false,\n    errors: false,\n  };\n  const _subjects: Subjects<TFieldValues> = {\n    watch: createSubject(),\n    array: createSubject(),\n    state: createSubject(),\n  };\n\n  const validationModeBeforeSubmit = getValidationModes(_options.mode);\n  const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);\n  const shouldDisplayAllAssociatedErrors =\n    _options.criteriaMode === VALIDATION_MODE.all;\n\n  const debounce =\n    <T extends Function>(callback: T) =>\n    (wait: number) => {\n      clearTimeout(timer);\n      timer = window.setTimeout(callback, wait);\n    };\n\n  const _updateValid = async (shouldSkipRender?: boolean) => {\n    let isValid = false;\n\n    if (_proxyFormState.isValid) {\n      isValid = _options.resolver\n        ? isEmptyObject((await _executeSchema()).errors)\n        : await executeBuiltInValidation(_fields, true);\n\n      if (!shouldSkipRender && isValid !== _formState.isValid) {\n        _formState.isValid = isValid;\n        _subjects.state.next({\n          isValid,\n        });\n      }\n    }\n\n    return isValid;\n  };\n\n  const _updateFieldArray: BatchFieldArrayUpdate = (\n    name,\n    values = [],\n    method,\n    args,\n    shouldSetValues = true,\n    shouldUpdateFieldsAndState = true,\n  ) => {\n    if (args && method) {\n      _stateFlags.action = true;\n      if (shouldUpdateFieldsAndState && Array.isArray(get(_fields, name))) {\n        const fieldValues = method(get(_fields, name), args.argA, args.argB);\n        shouldSetValues && set(_fields, name, fieldValues);\n      }\n\n      if (\n        _proxyFormState.errors &&\n        shouldUpdateFieldsAndState &&\n        Array.isArray(get(_formState.errors, name))\n      ) {\n        const errors = method(\n          get(_formState.errors, name),\n          args.argA,\n          args.argB,\n        );\n        shouldSetValues && set(_formState.errors, name, errors);\n        unsetEmptyArray(_formState.errors, name);\n      }\n\n      if (\n        _proxyFormState.touchedFields &&\n        shouldUpdateFieldsAndState &&\n        Array.isArray(get(_formState.touchedFields, name))\n      ) {\n        const touchedFields = method(\n          get(_formState.touchedFields, name),\n          args.argA,\n          args.argB,\n        );\n        shouldSetValues && set(_formState.touchedFields, name, touchedFields);\n      }\n\n      if (_proxyFormState.dirtyFields) {\n        _formState.dirtyFields = getDirtyFields(_defaultValues, _formValues);\n      }\n\n      _subjects.state.next({\n        isDirty: _getDirty(name, values),\n        dirtyFields: _formState.dirtyFields,\n        errors: _formState.errors,\n        isValid: _formState.isValid,\n      });\n    } else {\n      set(_formValues, name, values);\n    }\n  };\n\n  const updateErrors = (name: InternalFieldName, error: FieldError) => {\n    set(_formState.errors, name, error);\n    _subjects.state.next({\n      errors: _formState.errors,\n    });\n  };\n\n  const updateValidAndValue = (\n    name: InternalFieldName,\n    shouldSkipSetValueAs: boolean,\n    value?: unknown,\n    ref?: Ref,\n  ) => {\n    const field: Field = get(_fields, name);\n\n    if (field) {\n      const defaultValue = get(\n        _formValues,\n        name,\n        isUndefined(value) ? get(_defaultValues, name) : value,\n      );\n\n      isUndefined(defaultValue) ||\n      (ref && (ref as HTMLInputElement).defaultChecked) ||\n      shouldSkipSetValueAs\n        ? set(\n            _formValues,\n            name,\n            shouldSkipSetValueAs ? defaultValue : getFieldValue(field._f),\n          )\n        : setFieldValue(name, defaultValue);\n\n      _stateFlags.mount && _updateValid();\n    }\n  };\n\n  const updateTouchAndDirty = (\n    name: InternalFieldName,\n    fieldValue: unknown,\n    isBlurEvent?: boolean,\n    shouldDirty?: boolean,\n    shouldRender?: boolean,\n  ): Partial<\n    Pick<FormState<TFieldValues>, 'dirtyFields' | 'isDirty' | 'touchedFields'>\n  > => {\n    let isFieldDirty = false;\n    const output: Partial<FormState<TFieldValues>> & { name: string } = {\n      name,\n    };\n    const isPreviousFieldTouched = get(_formState.touchedFields, name);\n\n    if (_proxyFormState.isDirty) {\n      const isPreviousFormDirty = _formState.isDirty;\n\n      _formState.isDirty = output.isDirty = _getDirty();\n      isFieldDirty = isPreviousFormDirty !== output.isDirty;\n    }\n\n    if (_proxyFormState.dirtyFields && (!isBlurEvent || shouldDirty)) {\n      const isPreviousFieldDirty = get(_formState.dirtyFields, name);\n      const isCurrentFieldPristine = deepEqual(\n        get(_defaultValues, name),\n        fieldValue,\n      );\n\n      isCurrentFieldPristine\n        ? unset(_formState.dirtyFields, name)\n        : set(_formState.dirtyFields, name, true);\n      output.dirtyFields = _formState.dirtyFields;\n      isFieldDirty =\n        isFieldDirty ||\n        isPreviousFieldDirty !== get(_formState.dirtyFields, name);\n    }\n\n    if (isBlurEvent && !isPreviousFieldTouched) {\n      set(_formState.touchedFields, name, isBlurEvent);\n      output.touchedFields = _formState.touchedFields;\n      isFieldDirty =\n        isFieldDirty ||\n        (_proxyFormState.touchedFields &&\n          isPreviousFieldTouched !== isBlurEvent);\n    }\n\n    isFieldDirty && shouldRender && _subjects.state.next(output);\n\n    return isFieldDirty ? output : {};\n  };\n\n  const shouldRenderByError = async (\n    name: InternalFieldName,\n    isValid: boolean,\n    error?: FieldError,\n    fieldState?: {\n      dirty?: FieldNamesMarkedBoolean<TFieldValues>;\n      isDirty?: boolean;\n      touched?: FieldNamesMarkedBoolean<TFieldValues>;\n    },\n  ): Promise<void> => {\n    const previousFieldError = get(_formState.errors, name);\n    const shouldUpdateValid =\n      _proxyFormState.isValid && _formState.isValid !== isValid;\n\n    if (props.delayError && error) {\n      delayErrorCallback = debounce(() => updateErrors(name, error));\n      delayErrorCallback(props.delayError);\n    } else {\n      clearTimeout(timer);\n      delayErrorCallback = null;\n      error\n        ? set(_formState.errors, name, error)\n        : unset(_formState.errors, name);\n    }\n\n    if (\n      (error ? !deepEqual(previousFieldError, error) : previousFieldError) ||\n      !isEmptyObject(fieldState) ||\n      shouldUpdateValid\n    ) {\n      const updatedFormState = {\n        ...fieldState,\n        ...(shouldUpdateValid ? { isValid } : {}),\n        errors: _formState.errors,\n        name,\n      };\n\n      _formState = {\n        ..._formState,\n        ...updatedFormState,\n      };\n\n      _subjects.state.next(updatedFormState);\n    }\n\n    validateFields[name]--;\n\n    if (\n      _proxyFormState.isValidating &&\n      !Object.values(validateFields).some((v) => v)\n    ) {\n      _subjects.state.next({\n        isValidating: false,\n      });\n      validateFields = {};\n    }\n  };\n\n  const _executeSchema = async (name?: InternalFieldName[]) =>\n    _options.resolver\n      ? await _options.resolver(\n          { ..._formValues } as TFieldValues,\n          _options.context,\n          getResolverOptions(\n            name || _names.mount,\n            _fields,\n            _options.criteriaMode,\n            _options.shouldUseNativeValidation,\n          ),\n        )\n      : ({} as ResolverResult<TFieldValues>);\n\n  const executeSchemaAndUpdateState = async (names?: InternalFieldName[]) => {\n    const { errors } = await _executeSchema();\n\n    if (names) {\n      for (const name of names) {\n        const error = get(errors, name);\n        error\n          ? set(_formState.errors, name, error)\n          : unset(_formState.errors, name);\n      }\n    } else {\n      _formState.errors = errors;\n    }\n\n    return errors;\n  };\n\n  const executeBuiltInValidation = async (\n    fields: FieldRefs,\n    shouldOnlyCheckValid?: boolean,\n    context = {\n      valid: true,\n    },\n  ) => {\n    for (const name in fields) {\n      const field = fields[name];\n\n      if (field) {\n        const { _f, ...fieldValue } = field;\n\n        if (_f) {\n          const isFieldArrayRoot = _names.array.has(_f.name);\n          const fieldError = await validateField(\n            field,\n            get(_formValues, _f.name),\n            shouldDisplayAllAssociatedErrors,\n            _options.shouldUseNativeValidation,\n            isFieldArrayRoot,\n          );\n\n          if (fieldError[_f.name]) {\n            context.valid = false;\n\n            if (shouldOnlyCheckValid) {\n              break;\n            }\n          }\n\n          !shouldOnlyCheckValid &&\n            (get(fieldError, _f.name)\n              ? isFieldArrayRoot\n                ? updateFieldArrayRootError(\n                    _formState.errors,\n                    fieldError,\n                    _f.name,\n                  )\n                : set(_formState.errors, _f.name, fieldError[_f.name])\n              : unset(_formState.errors, _f.name));\n        }\n\n        fieldValue &&\n          (await executeBuiltInValidation(\n            fieldValue,\n            shouldOnlyCheckValid,\n            context,\n          ));\n      }\n    }\n\n    return context.valid;\n  };\n\n  const _removeUnmounted = () => {\n    for (const name of _names.unMount) {\n      const field: Field = get(_fields, name);\n\n      field &&\n        (field._f.refs\n          ? field._f.refs.every((ref) => !live(ref))\n          : !live(field._f.ref)) &&\n        unregister(name as FieldPath<TFieldValues>);\n    }\n\n    _names.unMount = new Set();\n  };\n\n  const _getDirty: GetIsDirty = (name, data) => (\n    name && data && set(_formValues, name, data),\n    !deepEqual(getValues(), _defaultValues)\n  );\n\n  const _getWatch: WatchInternal<TFieldValues> = (\n    names,\n    defaultValue,\n    isGlobal,\n  ) => {\n    const fieldValues = {\n      ...(_stateFlags.mount\n        ? _formValues\n        : isUndefined(defaultValue)\n        ? _defaultValues\n        : isString(names)\n        ? { [names]: defaultValue }\n        : defaultValue),\n    };\n\n    return generateWatchOutput(names, _names, fieldValues, isGlobal);\n  };\n\n  const _getFieldArray = <TFieldArrayValues>(\n    name: InternalFieldName,\n  ): Partial<TFieldArrayValues>[] =>\n    compact(\n      get(\n        _stateFlags.mount ? _formValues : _defaultValues,\n        name,\n        props.shouldUnregister ? get(_defaultValues, name, []) : [],\n      ),\n    );\n\n  const setFieldValue = (\n    name: InternalFieldName,\n    value: SetFieldValue<TFieldValues>,\n    options: SetValueConfig = {},\n  ) => {\n    const field: Field = get(_fields, name);\n    let fieldValue: unknown = value;\n\n    if (field) {\n      const fieldReference = field._f;\n\n      if (fieldReference) {\n        !fieldReference.disabled &&\n          set(_formValues, name, getFieldValueAs(value, fieldReference));\n\n        fieldValue =\n          isWeb && isHTMLElement(fieldReference.ref) && isNullOrUndefined(value)\n            ? ''\n            : value;\n\n        if (isMultipleSelect(fieldReference.ref)) {\n          [...fieldReference.ref.options].forEach(\n            (optionRef) =>\n              (optionRef.selected = (\n                fieldValue as InternalFieldName[]\n              ).includes(optionRef.value)),\n          );\n        } else if (fieldReference.refs) {\n          if (isCheckBoxInput(fieldReference.ref)) {\n            fieldReference.refs.length > 1\n              ? fieldReference.refs.forEach(\n                  (checkboxRef) =>\n                    (!checkboxRef.defaultChecked || !checkboxRef.disabled) &&\n                    (checkboxRef.checked = Array.isArray(fieldValue)\n                      ? !!(fieldValue as []).find(\n                          (data: string) => data === checkboxRef.value,\n                        )\n                      : fieldValue === checkboxRef.value),\n                )\n              : fieldReference.refs[0] &&\n                (fieldReference.refs[0].checked = !!fieldValue);\n          } else {\n            fieldReference.refs.forEach(\n              (radioRef: HTMLInputElement) =>\n                (radioRef.checked = radioRef.value === fieldValue),\n            );\n          }\n        } else if (isFileInput(fieldReference.ref)) {\n          fieldReference.ref.value = '';\n        } else {\n          fieldReference.ref.value = fieldValue;\n\n          if (!fieldReference.ref.type) {\n            _subjects.watch.next({\n              name,\n            });\n          }\n        }\n      }\n    }\n\n    (options.shouldDirty || options.shouldTouch) &&\n      updateTouchAndDirty(\n        name,\n        fieldValue,\n        options.shouldTouch,\n        options.shouldDirty,\n        true,\n      );\n\n    options.shouldValidate && trigger(name as Path<TFieldValues>);\n  };\n\n  const setValues = <\n    T extends InternalFieldName,\n    K extends SetFieldValue<TFieldValues>,\n    U extends SetValueConfig,\n  >(\n    name: T,\n    value: K,\n    options: U,\n  ) => {\n    for (const fieldKey in value) {\n      const fieldValue = value[fieldKey];\n      const fieldName = `${name}.${fieldKey}` as Path<TFieldValues>;\n      const field = get(_fields, fieldName);\n\n      (_names.array.has(name) ||\n        !isPrimitive(fieldValue) ||\n        (field && !field._f)) &&\n      !isDateObject(fieldValue)\n        ? setValues(fieldName, fieldValue, options)\n        : setFieldValue(fieldName, fieldValue, options);\n    }\n  };\n\n  const setValue: UseFormSetValue<TFieldValues> = (\n    name,\n    value,\n    options = {},\n  ) => {\n    const field = get(_fields, name);\n    const isFieldArray = _names.array.has(name);\n    const cloneValue = cloneObject(value);\n\n    set(_formValues, name, cloneValue);\n\n    if (isFieldArray) {\n      _subjects.array.next({\n        name,\n        values: _formValues,\n      });\n\n      if (\n        (_proxyFormState.isDirty || _proxyFormState.dirtyFields) &&\n        options.shouldDirty\n      ) {\n        _formState.dirtyFields = getDirtyFields(_defaultValues, _formValues);\n\n        _subjects.state.next({\n          name,\n          dirtyFields: _formState.dirtyFields,\n          isDirty: _getDirty(name, cloneValue),\n        });\n      }\n    } else {\n      field && !field._f && !isNullOrUndefined(cloneValue)\n        ? setValues(name, cloneValue, options)\n        : setFieldValue(name, cloneValue, options);\n    }\n\n    isWatched(name, _names) && _subjects.state.next({});\n    _subjects.watch.next({\n      name,\n    });\n  };\n\n  const onChange: ChangeHandler = async (event) => {\n    const target = event.target;\n    let name = target.name;\n    const field: Field = get(_fields, name);\n\n    if (field) {\n      let error;\n      let isValid;\n      const fieldValue = target.type\n        ? getFieldValue(field._f)\n        : getEventValue(event);\n      const isBlurEvent =\n        event.type === EVENTS.BLUR || event.type === EVENTS.FOCUS_OUT;\n      const shouldSkipValidation =\n        (!hasValidation(field._f) &&\n          !_options.resolver &&\n          !get(_formState.errors, name) &&\n          !field._f.deps) ||\n        skipValidation(\n          isBlurEvent,\n          get(_formState.touchedFields, name),\n          _formState.isSubmitted,\n          validationModeAfterSubmit,\n          validationModeBeforeSubmit,\n        );\n      const watched = isWatched(name, _names, isBlurEvent);\n\n      set(_formValues, name, fieldValue);\n\n      if (isBlurEvent) {\n        field._f.onBlur && field._f.onBlur(event);\n        delayErrorCallback && delayErrorCallback(0);\n      } else if (field._f.onChange) {\n        field._f.onChange(event);\n      }\n\n      const fieldState = updateTouchAndDirty(\n        name,\n        fieldValue,\n        isBlurEvent,\n        false,\n      );\n\n      const shouldRender = !isEmptyObject(fieldState) || watched;\n\n      !isBlurEvent &&\n        _subjects.watch.next({\n          name,\n          type: event.type,\n        });\n\n      if (shouldSkipValidation) {\n        return (\n          shouldRender &&\n          _subjects.state.next({ name, ...(watched ? {} : fieldState) })\n        );\n      }\n\n      !isBlurEvent && watched && _subjects.state.next({});\n\n      validateFields[name] = validateFields[name] ? +1 : 1;\n\n      _subjects.state.next({\n        isValidating: true,\n      });\n\n      if (_options.resolver) {\n        const { errors } = await _executeSchema([name]);\n        const previousErrorLookupResult = schemaErrorLookup(\n          _formState.errors,\n          _fields,\n          name,\n        );\n        const errorLookupResult = schemaErrorLookup(\n          errors,\n          _fields,\n          previousErrorLookupResult.name || name,\n        );\n\n        error = errorLookupResult.error;\n        name = errorLookupResult.name;\n\n        isValid = isEmptyObject(errors);\n      } else {\n        error = (\n          await validateField(\n            field,\n            get(_formValues, name),\n            shouldDisplayAllAssociatedErrors,\n            _options.shouldUseNativeValidation,\n          )\n        )[name];\n\n        isValid = await _updateValid(true);\n      }\n\n      field._f.deps &&\n        trigger(\n          field._f.deps as FieldPath<TFieldValues> | FieldPath<TFieldValues>[],\n        );\n\n      shouldRenderByError(name, isValid, error, fieldState);\n    }\n  };\n\n  const trigger: UseFormTrigger<TFieldValues> = async (name, options = {}) => {\n    let isValid;\n    let validationResult;\n    const fieldNames = convertToArrayPayload(name) as InternalFieldName[];\n\n    _subjects.state.next({\n      isValidating: true,\n    });\n\n    if (_options.resolver) {\n      const errors = await executeSchemaAndUpdateState(\n        isUndefined(name) ? name : fieldNames,\n      );\n\n      isValid = isEmptyObject(errors);\n      validationResult = name\n        ? !fieldNames.some((name) => get(errors, name))\n        : isValid;\n    } else if (name) {\n      validationResult = (\n        await Promise.all(\n          fieldNames.map(async (fieldName) => {\n            const field = get(_fields, fieldName);\n            return await executeBuiltInValidation(\n              field && field._f ? { [fieldName]: field } : field,\n            );\n          }),\n        )\n      ).every(Boolean);\n      !(!validationResult && !_formState.isValid) && _updateValid();\n    } else {\n      validationResult = isValid = await executeBuiltInValidation(_fields);\n    }\n\n    _subjects.state.next({\n      ...(!isString(name) ||\n      (_proxyFormState.isValid && isValid !== _formState.isValid)\n        ? {}\n        : { name }),\n      ...(_options.resolver || !name ? { isValid } : {}),\n      errors: _formState.errors,\n      isValidating: false,\n    });\n\n    options.shouldFocus &&\n      !validationResult &&\n      focusFieldBy(\n        _fields,\n        (key) => key && get(_formState.errors, key),\n        name ? fieldNames : _names.mount,\n      );\n\n    return validationResult;\n  };\n\n  const getValues: UseFormGetValues<TFieldValues> = (\n    fieldNames?:\n      | FieldPath<TFieldValues>\n      | ReadonlyArray<FieldPath<TFieldValues>>,\n  ) => {\n    const values = {\n      ..._defaultValues,\n      ...(_stateFlags.mount ? _formValues : {}),\n    };\n\n    return isUndefined(fieldNames)\n      ? values\n      : isString(fieldNames)\n      ? get(values, fieldNames as InternalFieldName)\n      : fieldNames.map((name) => get(values, name as InternalFieldName));\n  };\n\n  const getFieldState: UseFormGetFieldState<TFieldValues> = (\n    name,\n    formState,\n  ) => ({\n    invalid: !!get((formState || _formState).errors, name),\n    isDirty: !!get((formState || _formState).dirtyFields, name),\n    isTouched: !!get((formState || _formState).touchedFields, name),\n    error: get((formState || _formState).errors, name),\n  });\n\n  const clearErrors: UseFormClearErrors<TFieldValues> = (name) => {\n    name\n      ? convertToArrayPayload(name).forEach((inputName) =>\n          unset(_formState.errors, inputName),\n        )\n      : (_formState.errors = {});\n\n    _subjects.state.next({\n      errors: _formState.errors,\n    });\n  };\n\n  const setError: UseFormSetError<TFieldValues> = (name, error, options) => {\n    const ref = ((get(_fields, name, { _f: {} }) as Field)._f || {}).ref;\n\n    set(_formState.errors, name, {\n      ...error,\n      ref,\n    });\n\n    _subjects.state.next({\n      name,\n      errors: _formState.errors,\n      isValid: false,\n    });\n\n    options && options.shouldFocus && ref && ref.focus && ref.focus();\n  };\n\n  const watch: UseFormWatch<TFieldValues> = (\n    name?:\n      | FieldPath<TFieldValues>\n      | ReadonlyArray<FieldPath<TFieldValues>>\n      | WatchObserver<TFieldValues>,\n    defaultValue?: unknown,\n  ) =>\n    isFunction(name)\n      ? _subjects.watch.subscribe({\n          next: (info) =>\n            name(\n              _getWatch(undefined, defaultValue as DeepPartial<TFieldValues>),\n              info as {\n                name?: FieldPath<TFieldValues>;\n                type?: EventType;\n                value?: unknown;\n              },\n            ),\n        })\n      : _getWatch(\n          name as InternalFieldName | InternalFieldName[],\n          defaultValue as DeepPartial<TFieldValues>,\n          true,\n        );\n\n  const unregister: UseFormUnregister<TFieldValues> = (name, options = {}) => {\n    for (const fieldName of name ? convertToArrayPayload(name) : _names.mount) {\n      _names.mount.delete(fieldName);\n      _names.array.delete(fieldName);\n\n      if (get(_fields, fieldName)) {\n        if (!options.keepValue) {\n          unset(_fields, fieldName);\n          unset(_formValues, fieldName);\n        }\n\n        !options.keepError && unset(_formState.errors, fieldName);\n        !options.keepDirty && unset(_formState.dirtyFields, fieldName);\n        !options.keepTouched && unset(_formState.touchedFields, fieldName);\n        !_options.shouldUnregister &&\n          !options.keepDefaultValue &&\n          unset(_defaultValues, fieldName);\n      }\n    }\n\n    _subjects.watch.next({});\n\n    _subjects.state.next({\n      ..._formState,\n      ...(!options.keepDirty ? {} : { isDirty: _getDirty() }),\n    });\n\n    !options.keepIsValid && _updateValid();\n  };\n\n  const register: UseFormRegister<TFieldValues> = (name, options = {}) => {\n    let field = get(_fields, name);\n    const disabledIsDefined = isBoolean(options.disabled);\n\n    set(_fields, name, {\n      ...(field || {}),\n      _f: {\n        ...(field && field._f ? field._f : { ref: { name } }),\n        name,\n        mount: true,\n        ...options,\n      },\n    });\n    _names.mount.add(name);\n\n    field\n      ? disabledIsDefined &&\n        set(\n          _formValues,\n          name,\n          options.disabled\n            ? undefined\n            : get(_formValues, name, getFieldValue(field._f)),\n        )\n      : updateValidAndValue(name, true, options.value);\n\n    return {\n      ...(disabledIsDefined ? { disabled: options.disabled } : {}),\n      ...(_options.shouldUseNativeValidation\n        ? {\n            required: !!options.required,\n            min: getRuleValue(options.min),\n            max: getRuleValue(options.max),\n            minLength: getRuleValue<number>(options.minLength) as number,\n            maxLength: getRuleValue(options.maxLength) as number,\n            pattern: getRuleValue(options.pattern) as string,\n          }\n        : {}),\n      name,\n      onChange,\n      onBlur: onChange,\n      ref: (ref: HTMLInputElement | null): void => {\n        if (ref) {\n          register(name, options);\n          field = get(_fields, name);\n\n          const fieldRef = isUndefined(ref.value)\n            ? ref.querySelectorAll\n              ? (ref.querySelectorAll('input,select,textarea')[0] as Ref) || ref\n              : ref\n            : ref;\n          const radioOrCheckbox = isRadioOrCheckbox(fieldRef);\n          const refs = field._f.refs || [];\n\n          if (\n            radioOrCheckbox\n              ? refs.find((option: Ref) => option === fieldRef)\n              : fieldRef === field._f.ref\n          ) {\n            return;\n          }\n\n          set(_fields, name, {\n            _f: {\n              ...field._f,\n              ...(radioOrCheckbox\n                ? {\n                    refs: [\n                      ...refs.filter(live),\n                      fieldRef,\n                      ...(!!Array.isArray(get(_defaultValues, name))\n                        ? [{}]\n                        : []),\n                    ],\n                    ref: { type: fieldRef.type, name },\n                  }\n                : { ref: fieldRef }),\n            },\n          });\n\n          updateValidAndValue(name, false, undefined, fieldRef);\n        } else {\n          field = get(_fields, name, {});\n\n          if (field._f) {\n            field._f.mount = false;\n          }\n\n          (_options.shouldUnregister || options.shouldUnregister) &&\n            !(isNameInFieldArray(_names.array, name) && _stateFlags.action) &&\n            _names.unMount.add(name);\n        }\n      },\n    };\n  };\n\n  const _focusError = () =>\n    _options.shouldFocusError &&\n    focusFieldBy(\n      _fields,\n      (key) => key && get(_formState.errors, key),\n      _names.mount,\n    );\n\n  const handleSubmit: UseFormHandleSubmit<TFieldValues> =\n    (onValid, onInvalid) => async (e) => {\n      if (e) {\n        e.preventDefault && e.preventDefault();\n        e.persist && e.persist();\n      }\n      let hasNoPromiseError = true;\n      let fieldValues: any = cloneObject(_formValues);\n\n      _subjects.state.next({\n        isSubmitting: true,\n      });\n\n      try {\n        if (_options.resolver) {\n          const { errors, values } = await _executeSchema();\n          _formState.errors = errors;\n          fieldValues = values;\n        } else {\n          await executeBuiltInValidation(_fields);\n        }\n\n        if (isEmptyObject(_formState.errors)) {\n          _subjects.state.next({\n            errors: {},\n            isSubmitting: true,\n          });\n          await onValid(fieldValues, e);\n        } else {\n          if (onInvalid) {\n            await onInvalid({ ..._formState.errors }, e);\n          }\n\n          _focusError();\n        }\n      } catch (err) {\n        hasNoPromiseError = false;\n        throw err;\n      } finally {\n        _formState.isSubmitted = true;\n        _subjects.state.next({\n          isSubmitted: true,\n          isSubmitting: false,\n          isSubmitSuccessful:\n            isEmptyObject(_formState.errors) && hasNoPromiseError,\n          submitCount: _formState.submitCount + 1,\n          errors: _formState.errors,\n        });\n      }\n    };\n\n  const resetField: UseFormResetField<TFieldValues> = (name, options = {}) => {\n    if (get(_fields, name)) {\n      if (isUndefined(options.defaultValue)) {\n        setValue(name, get(_defaultValues, name));\n      } else {\n        setValue(name, options.defaultValue);\n        set(_defaultValues, name, options.defaultValue);\n      }\n\n      if (!options.keepTouched) {\n        unset(_formState.touchedFields, name);\n      }\n\n      if (!options.keepDirty) {\n        unset(_formState.dirtyFields, name);\n        _formState.isDirty = options.defaultValue\n          ? _getDirty(name, get(_defaultValues, name))\n          : _getDirty();\n      }\n\n      if (!options.keepError) {\n        unset(_formState.errors, name);\n        _proxyFormState.isValid && _updateValid();\n      }\n\n      _subjects.state.next({ ..._formState });\n    }\n  };\n\n  const _reset: UseFormReset<TFieldValues> = (\n    formValues,\n    keepStateOptions = {},\n  ) => {\n    const updatedValues = formValues || _defaultValues;\n    const cloneUpdatedValues = cloneObject(updatedValues);\n    const values =\n      formValues && !isEmptyObject(formValues)\n        ? cloneUpdatedValues\n        : _defaultValues;\n\n    if (!keepStateOptions.keepDefaultValues) {\n      _defaultValues = updatedValues;\n    }\n\n    if (!keepStateOptions.keepValues) {\n      if (keepStateOptions.keepDirtyValues) {\n        for (const fieldName of _names.mount) {\n          get(_formState.dirtyFields, fieldName)\n            ? set(values, fieldName, get(_formValues, fieldName))\n            : setValue(\n                fieldName as FieldPath<TFieldValues>,\n                get(values, fieldName),\n              );\n        }\n      } else {\n        if (isWeb && isUndefined(formValues)) {\n          for (const name of _names.mount) {\n            const field = get(_fields, name);\n            if (field && field._f) {\n              const fieldReference = Array.isArray(field._f.refs)\n                ? field._f.refs[0]\n                : field._f.ref;\n\n              try {\n                if (isHTMLElement(fieldReference)) {\n                  fieldReference.closest('form')!.reset();\n                  break;\n                }\n              } catch {}\n            }\n          }\n        }\n\n        _fields = {};\n      }\n\n      _formValues = props.shouldUnregister\n        ? keepStateOptions.keepDefaultValues\n          ? cloneObject(_defaultValues)\n          : {}\n        : cloneUpdatedValues;\n\n      _subjects.array.next({\n        values,\n      });\n\n      _subjects.watch.next({\n        values,\n      });\n    }\n\n    _names = {\n      mount: new Set(),\n      unMount: new Set(),\n      array: new Set(),\n      watch: new Set(),\n      watchAll: false,\n      focus: '',\n    };\n\n    _stateFlags.mount =\n      !_proxyFormState.isValid || !!keepStateOptions.keepIsValid;\n\n    _stateFlags.watch = !!props.shouldUnregister;\n\n    _subjects.state.next({\n      submitCount: keepStateOptions.keepSubmitCount\n        ? _formState.submitCount\n        : 0,\n      isDirty:\n        keepStateOptions.keepDirty || keepStateOptions.keepDirtyValues\n          ? _formState.isDirty\n          : !!(\n              keepStateOptions.keepDefaultValues &&\n              !deepEqual(formValues, _defaultValues)\n            ),\n      isSubmitted: keepStateOptions.keepIsSubmitted\n        ? _formState.isSubmitted\n        : false,\n      dirtyFields:\n        keepStateOptions.keepDirty || keepStateOptions.keepDirtyValues\n          ? _formState.dirtyFields\n          : keepStateOptions.keepDefaultValues && formValues\n          ? getDirtyFields(_defaultValues, formValues)\n          : {},\n      touchedFields: keepStateOptions.keepTouched\n        ? _formState.touchedFields\n        : {},\n      errors: keepStateOptions.keepErrors ? _formState.errors : {},\n      isSubmitting: false,\n      isSubmitSuccessful: false,\n    });\n  };\n\n  const reset: UseFormReset<TFieldValues> = (formValues, keepStateOptions) =>\n    _reset(\n      isFunction(formValues)\n        ? formValues(_formValues as TFieldValues)\n        : formValues,\n      keepStateOptions,\n    );\n\n  const setFocus: UseFormSetFocus<TFieldValues> = (name, options = {}) => {\n    const field = get(_fields, name);\n    const fieldReference = field && field._f;\n\n    if (fieldReference) {\n      const fieldRef = fieldReference.refs\n        ? fieldReference.refs[0]\n        : fieldReference.ref;\n\n      if (fieldRef.focus) {\n        fieldRef.focus();\n        options.shouldSelect && fieldRef.select();\n      }\n    }\n  };\n\n  return {\n    control: {\n      register,\n      unregister,\n      getFieldState,\n      _executeSchema,\n      _focusError,\n      _getWatch,\n      _getDirty,\n      _updateValid,\n      _removeUnmounted,\n      _updateFieldArray,\n      _getFieldArray,\n      _subjects,\n      _proxyFormState,\n      get _fields() {\n        return _fields;\n      },\n      get _formValues() {\n        return _formValues;\n      },\n      get _stateFlags() {\n        return _stateFlags;\n      },\n      set _stateFlags(value) {\n        _stateFlags = value;\n      },\n      get _defaultValues() {\n        return _defaultValues;\n      },\n      get _names() {\n        return _names;\n      },\n      set _names(value) {\n        _names = value;\n      },\n      get _formState() {\n        return _formState;\n      },\n      set _formState(value) {\n        _formState = value;\n      },\n      get _options() {\n        return _options;\n      },\n      set _options(value) {\n        _options = {\n          ..._options,\n          ...value,\n        };\n      },\n    },\n    trigger,\n    register,\n    handleSubmit,\n    watch,\n    setValue,\n    getValues,\n    reset,\n    resetField,\n    clearErrors,\n    unregister,\n    setError,\n    setFocus,\n    getFieldState,\n  };\n}\n","import React from 'react';\n\nimport { createFormControl } from './logic/createFormControl';\nimport getProxyFormState from './logic/getProxyFormState';\nimport shouldRenderFormState from './logic/shouldRenderFormState';\nimport { FieldValues, FormState, UseFormProps, UseFormReturn } from './types';\nimport { useSubscribe } from './useSubscribe';\n\n/**\n * Custom hook to manage the entire form.\n *\n * @remarks\n * [API](https://react-hook-form.com/api/useform) • [Demo](https://codesandbox.io/s/react-hook-form-get-started-ts-5ksmm) • [Video](https://www.youtube.com/watch?v=RkXv4AXXC_4)\n *\n * @param props - form configuration and validation parameters.\n *\n * @returns methods - individual functions to manage the form state. {@link UseFormReturn}\n *\n * @example\n * ```tsx\n * function App() {\n *   const { register, handleSubmit, watch, formState: { errors } } = useForm();\n *   const onSubmit = data => console.log(data);\n *\n *   console.log(watch(\"example\"));\n *\n *   return (\n *     <form onSubmit={handleSubmit(onSubmit)}>\n *       <input defaultValue=\"test\" {...register(\"example\")} />\n *       <input {...register(\"exampleRequired\", { required: true })} />\n *       {errors.exampleRequired && <span>This field is required</span>}\n *       <input type=\"submit\" />\n *     </form>\n *   );\n * }\n * ```\n */\nexport function useForm<\n  TFieldValues extends FieldValues = FieldValues,\n  TContext = any,\n>(\n  props: UseFormProps<TFieldValues, TContext> = {},\n): UseFormReturn<TFieldValues, TContext> {\n  const _formControl = React.useRef<\n    UseFormReturn<TFieldValues, TContext> | undefined\n  >();\n  const [formState, updateFormState] = React.useState<FormState<TFieldValues>>({\n    isDirty: false,\n    isValidating: false,\n    isSubmitted: false,\n    isSubmitting: false,\n    isSubmitSuccessful: false,\n    isValid: false,\n    submitCount: 0,\n    dirtyFields: {},\n    touchedFields: {},\n    errors: {},\n    defaultValues: props.defaultValues,\n  });\n\n  if (!_formControl.current) {\n    _formControl.current = {\n      ...createFormControl(props),\n      formState,\n    };\n  }\n\n  const control = _formControl.current.control;\n  control._options = props;\n\n  useSubscribe({\n    subject: control._subjects.state,\n    callback: React.useCallback(\n      (value: FieldValues) => {\n        if (shouldRenderFormState(value, control._proxyFormState, true)) {\n          control._formState = {\n            ...control._formState,\n            ...value,\n          };\n\n          updateFormState({ ...control._formState });\n        }\n      },\n      [control],\n    ),\n  });\n\n  React.useEffect(() => {\n    if (!control._stateFlags.mount) {\n      control._proxyFormState.isValid && control._updateValid();\n      control._stateFlags.mount = true;\n    }\n\n    if (control._stateFlags.watch) {\n      control._stateFlags.watch = false;\n      control._subjects.state.next({});\n    }\n\n    control._removeUnmounted();\n  });\n\n  React.useEffect(() => {\n    formState.submitCount && control._focusError();\n  }, [control, formState.submitCount]);\n\n  _formControl.current.formState = getProxyFormState(formState, control);\n\n  return _formControl.current;\n}\n"]},"metadata":{},"sourceType":"module"}